Ajaxify a Hyperlink in an UpdatePanel

Last post 04-16-2007 1:09 AM by Fredrik N. 1 replies.

Sort Posts:

  • Ajaxify a Hyperlink in an UpdatePanel

    04-16-2007, 12:52 AM
    • Member
      43 point Member
    • craigmcg
    • Member since 01-26-2005, 8:21 PM
    • Auckland, New Zealand
    • Posts 16

    I have a gridview with a hyperlink column in an UpdatePanel.

    When a hyperlink is used it reloads another control based on the link clicked i.e. link constructs a querystring like ?id=2, however I want this to work within the UpdatePanel with a partial postback.

    How do I do this?

     

    - Craig McGuff
  • Re: Ajaxify a Hyperlink in an UpdatePanel

    04-16-2007, 1:09 AM
    • All-Star
      29,644 point All-Star
    • Fredrik N
    • Member since 06-22-2002, 1:03 AM
    • Sweden
    • Posts 5,334
    • TrustedFriends-MVPs

    The UpdatePanel will be updated if a control inside of the UpdatePanel does a postback (it will in that case do a async postback) or if you use triggers to a control that do a postback. You HyperLink will no do a postback, it will tell the Browser to point to a new address. So to solve it you can convert your HyperLink to a LinkButton control instead, hook up to the Click event of the LinkButton and write the code that should "reload" your other control If your "other" control in this case is within the UpdatePanel where you will put the LinkButton, the changes made to the control when you press on the LinkButton will be displayed. If you "other" control is outside of the UpdatePanel, it will no be updated. In this case you can for example move the "other" control into your UpdatePanel, or put it into a new UpdatePanel so it will be updated when the async postback of the LinkButton has taken place.

    /Fredrik Normén - fredrikn @ twitter

    ASPInsider

    Microsoft MVP, MCSD, MCAD, MCT

    ASPInsiders
    My Blog
Page 1 of 1 (2 items)