0

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...

1 Answer 1

1

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/

Sign up to request clarification or add additional context in comments.

1 Comment

It is possible in C# .why you need C# ? this can be achievable using js and C# requires a page load etc. Here you can easily manipulate the controls using js and jquery, but you must have a server side validation to verify the data

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.