I’m developing a C# ASP.NET application under VS2010. I want to generate a dynamic table by writing HTML text into a literal, including dynamically inserted buttons on my table. I know how to create dynamic ASP.NET controls, but I have a small problem with dynamic HTML controls. I’ve created an HTML button but I don’t know how to give it a server-side click function.
Can I create dynamic ASP.NET controls and insert them in my literal? How can I get a dynamically created button to trigger a server-side event?
I’ve used OnServerClick property for defining my server side function but it has no effect, how can I use this value?
If you want post back on your button click, you will have to add
__doPostBackfunction on it’sonclickevent, for this you can add a button likewhen you click on it, it will post back, and you can check
Request.Form["__EVENTTARGET"]to find who post back the page.By checking
Request.Form["__EVENTTARGET"]in Page_Load event handler, you can call your any server side method like