Results 1 to 4 of 4

Thread: add control through html string, addhandler?

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    9

    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!

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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

  3. #3
    Lively Member
    Join Date
    Oct 2008
    Posts
    87

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

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width