add control through html string, addhandler?
I have a dynamic asp.net web page in which I build html strings in vb.net and return them to the asp.net page.
I'm trying to add a control (specifically a button).
I am able to do this quite easily, but where i'm stuck is I do not know how to add a handler for the click event of this button.
here is the line of vb code that returns the html string.
Me.html = Me.html & "<button name=""b_ViewSearchOptions"" runat=""server"">View Search Options</button>"
the asp.net code would look like this..
<%=html%>
any help is greatly appreciated!
Re: add control through html string, addhandler?
You can't do that. When you generate code to write to the page, that's final. You can, however, use javascript to force a postback. Have a look at this example and modify it to fit your HTML generation.
http://www.dotnetspider.com/resource...avascript.aspx
Re: add control through html string, addhandler?
Are you trying to call a function here. i dont understand what your asking for. If your just trying to call an event handler of a buton
Quote:
I do not know how to add a handler for the click event of this button.
then why not use <asp:button etc /> and follow it up on the vb with an button.onclick method?
Re: add control through html string, addhandler?
He's generating HTML and writing it straight out to the page. Imagine an extremely large Literal control.