Adelhejtfax
New Member
Hi,<BR><BR>I need to be able to dynamically create a series of buttons at run-time <BR>(preferrably within a custom ASP.NET server control), and setup an <BR>eventhandler to respond to any one of these buttons being clicked. These <BR>buttons will actually represent diary text entries which have been loaded <BR>from a database, and clicking on an entry will allow the user to edit it. <BR><BR>I have been experimenting using the ASP:Literal control, which allows you <BR>to dynamically alter HTML code from the server side. But, my problem is <BR>after I have created a dynamic link (button) to a diary entry eg:<BR><BR>.ASPX file:<BR><asp:Literal Id="TestLiteral" RunAt="server" /><BR><BR>.cs (code-behind file):<BR>public Literal TestLiteral <BR><BR>TestLiteral.Text ="<asp:Button Id='TestEntry1' Text ='12pm Team Meeting' <BR>Runat='Server' OnClick='HandleEdit'/>"<BR><BR>public void HandleEdit( Object Source, EventArgs E )<BR>{<BR> /* process edit */<BR>}<BR><BR>that the Click event does not fire as I can't dynamically create a server <BR>side variable to represent the button. Can anyone point me in the right <BR>direction to creating some controls dynamically, which can respond to <BR>events from the client. <BR><BR>Many thanks,<BR>Richard.