0

its a bit complicatet to explain, but I hope I can make it clear:

In my BackEnd I have an StringBuilder in which I write HTML-Code for the FrontEnd and assign it to a Div.InnerHTML to show. Now in this code I must have a possibiliy to call a BackEnd-Method like I would normaly do with a LinkButton, but a LinkButton isn't a LinkButton when it's shown in HTML so I cant work with here.

A bit of code:

 StringBuilder sb = new StringBuilder();
 sb.AppendLine("<td>");
 sb.AppendLine("Test ");
//Here I need to insert a Button that calls a BackEnd-Method From the FrontEnd but Written in BackEnd
 sb.AppendLine("</td>");
 div.innerHTML = sb.ToString();
PassionateDeveloper
  • 14,558
  • 34
  • 107
  • 176

1 Answers1

1

I recommend attaching a CSS class name via the CssClass property of your dynamically created button.

Then have jQuery handle the click of the button via event delegation using the on () function.

Read jQuery on() function documentation for more information.

Once you have jQuery handing the event client side, then you have several choices of interacting with the server (__dopostback, ASP.NET AJAX Page Methods, ASP.NET Web API, asmx web services, WCF, etc.).

Karl Anderson
  • 34,606
  • 12
  • 65
  • 80