LIH
LIH

Reputation: 933

Add asp imagebutton inside javascript

I need to add asp image button inside a javascript function. Actually I need to create image buttons inside a html table dynamically. Here is my code. I need to add the image button where I have mentioned as "--- Here I need to add the image button ---"

function tableSeats() {
  document.write("<table align=center>");
  for (var i = 1; i <= 5; i++) {

      document.write("<tr height=30px>");

      for (var r = 1; r <= 10; r++) {
          document.write("<td width=30px>");
          document.write(--- Here I need to add the image button ---);
          document.write("</td>");
      }

      document.write("</tr>");
  }
  document.write("</table>");
}

If this is not possible, please tell me a way to do it using c#.net Thanks in advance...

Upvotes: 0

Views: 196

Answers (1)

kbvishnu
kbvishnu

Reputation: 15650

I believe by using javaScript you are not able to create any kind of server controls like image button and all. But you can do some kind of things like <img /> And using jQuery you can invoke the client click and using ajax you can easily communicate with server.

function tableSeats() {

  document.write("<table align=center>");
  for (var i = 1; i <= 5; i++) {

      document.write("<tr height=30px>");

      for (var r = 1; r <= 10; r++) {
          document.write("<td width=30px>");
          document.write("<img src='Your picture path' alt='' />");
          document.write("</td>");
      }

      document.write("</tr>");
  }
  document.write("</table>");
}

Updated the code

Check this for jQuery click http://api.jquery.com/click/

Upvotes: 1

Related Questions