UpdatePanels, LinkButtons, and PostBackUrls

Discussion in 'ASP .Net' started by Nathan Sokalski, Sep 11, 2008.

  1. I have an UpdatePanel that contains a LinkButton with a PostBackUrl. The
    LinkButton is marked as a PostBackTrigger, so it does a full postback.
    However, when it posts back, it goes straight to the page specified in the
    PostBackUrl. I always thought (and the way I have always used it in the
    past, where it worked) that it posted back to the page the button is on,
    executed the stuff like Page_Load and the eventhandler for the button's
    Click event, created the PreviousPage property, and then went to the page
    specified in PostBackUrl. When using PostBackUrl, is it supposed to execute
    the current page before going to the one specified in the PostBackUrl
    property? Thanks.

    Nathan Sokalski

    http://www.nathansokalski.com/
    Nathan Sokalski, Sep 11, 2008
    #1
    1. Advertising

  2. Hi Nathan,

    You might be confusing the PostBackUrl functionality with the
    Server.Transfer or Response.Redirect call. The PostBackUrl functionality
    actually sets the action property of the form to the specified URL, so the
    browser makes the post request towards it.

    To have some of the source page life cycle steps executed first, you can use
    a normal postback and then either use Response.Redirect, or Server.Transfer.
    You could prefer Server.Transfer if you need to access the post data from
    the target page.

    Cheers,
    Erjan

    "Nathan Sokalski" <> wrote in message
    news:...
    >I have an UpdatePanel that contains a LinkButton with a PostBackUrl. The
    >LinkButton is marked as a PostBackTrigger, so it does a full postback.
    >However, when it posts back, it goes straight to the page specified in the
    >PostBackUrl. I always thought (and the way I have always used it in the
    >past, where it worked) that it posted back to the page the button is on,
    >executed the stuff like Page_Load and the eventhandler for the button's
    >Click event, created the PreviousPage property, and then went to the page
    >specified in PostBackUrl. When using PostBackUrl, is it supposed to execute
    >the current page before going to the one specified in the PostBackUrl
    >property? Thanks.
    >
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/
    >
    Erjan Gavalji, Sep 11, 2008
    #2
    1. Advertising

  3. That is probably true, but something I found on the web after making my
    original post was that the events from the source page I mentioned
    (Page_Load, Click, etc.) are executed only if the PreviousPage property is
    accessed on the target page. The author of the page I got was not sure why
    this was the situation, but when I added a statement to my target page that
    used the PreviousPage property, these events were executed, so I guess it
    does work this way. I'm sure there is a little more detail to it somewhere,
    but for now, this lets me do what I want.

    Nathan Sokalski

    http://www.nathansokalski.com/

    "Erjan Gavalji" <> wrote in message
    news:...
    > Hi Nathan,
    >
    > You might be confusing the PostBackUrl functionality with the
    > Server.Transfer or Response.Redirect call. The PostBackUrl functionality
    > actually sets the action property of the form to the specified URL, so the
    > browser makes the post request towards it.
    >
    > To have some of the source page life cycle steps executed first, you can
    > use a normal postback and then either use Response.Redirect, or
    > Server.Transfer. You could prefer Server.Transfer if you need to access
    > the post data from the target page.
    >
    > Cheers,
    > Erjan
    >
    > "Nathan Sokalski" <> wrote in message
    > news:...
    >>I have an UpdatePanel that contains a LinkButton with a PostBackUrl. The
    >>LinkButton is marked as a PostBackTrigger, so it does a full postback.
    >>However, when it posts back, it goes straight to the page specified in the
    >>PostBackUrl. I always thought (and the way I have always used it in the
    >>past, where it worked) that it posted back to the page the button is on,
    >>executed the stuff like Page_Load and the eventhandler for the button's
    >>Click event, created the PreviousPage property, and then went to the page
    >>specified in PostBackUrl. When using PostBackUrl, is it supposed to
    >>execute the current page before going to the one specified in the
    >>PostBackUrl property? Thanks.
    >>
    >> Nathan Sokalski
    >>
    >> http://www.nathansokalski.com/
    >>

    >
    Nathan Sokalski, Sep 11, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?cml2YWxAbmV3c2dyb3Vwcy5ub3NwYW0=?=

    UpdatePanels refresh other UpdatePanels when UpdateMode is 'Condit

    =?Utf-8?B?cml2YWxAbmV3c2dyb3Vwcy5ub3NwYW0=?=, Jul 28, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    420
    Masudur
    Jul 28, 2007
  2. Mike Gleason jr Couturier

    Delegates and UpdatePanels

    Mike Gleason jr Couturier, Aug 7, 2008, in forum: ASP .Net
    Replies:
    0
    Views:
    339
    Mike Gleason jr Couturier
    Aug 7, 2008
  3. Marc
    Replies:
    5
    Views:
    355
    Steven Cheng [MSFT]
    Aug 27, 2008
  4. Nathan Sokalski

    UpdatePanels, LinkButtons, and PostBackUrls

    Nathan Sokalski, Sep 11, 2008, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    122
    Nathan Sokalski
    Sep 11, 2008
  5. Marc
    Replies:
    2
    Views:
    107
Loading...

Share This Page