PostbackUrl

Discussion in 'ASP .Net Web Controls' started by Nutan, May 14, 2008.

  1. Nutan

    Nutan Guest

    Hello,

    I am facing a problem in using PostbackUrl property in asp.net.
    I have set value for PostBackUrl property of asp:Button control.
    Fine, that it redirects user to another page, allowing me to access all
    properties, controls of previous page.

    But problem comes when my current page is having some error and i want to
    report these errors to user,
    but instead of staying on the same page, it redirects user to another page.

    How can i stop user to be redirected to another page, when PostbackUrl
    property is set.

    Thanx and Regards
    Nutan
    Nutan, May 14, 2008
    #1
    1. Advertising

  2. Nutan

    Teemu Keiski Guest

    Hi,

    could you use validation controls to detect these errors? You could also
    have some script of your own to prevent cross-page postback from happening
    if it could be detectable from client-side script.

    In anycase you can check the validity on the target page

    if (PreviousPage != null && !PreviousPage.IsValid)

    {

    Response.Write("Wrong...");


    }


    --
    Teemu Keiski
    AspInsider, ASP.NET MVP
    http://blogs.aspadvice.com/joteke
    http://teemukeiski.net





    "Nutan" <> wrote in message
    news:...
    > Hello,
    >
    > I am facing a problem in using PostbackUrl property in asp.net.
    > I have set value for PostBackUrl property of asp:Button control.
    > Fine, that it redirects user to another page, allowing me to access all
    > properties, controls of previous page.
    >
    > But problem comes when my current page is having some error and i want to
    > report these errors to user,
    > but instead of staying on the same page, it redirects user to another
    > page.
    >
    > How can i stop user to be redirected to another page, when PostbackUrl
    > property is set.
    >
    > Thanx and Regards
    > Nutan
    >
    Teemu Keiski, May 18, 2008
    #2
    1. Advertising

  3. Nutan

    Nutan Guest

    Hello Teemu,

    Thanks for the reply.
    Actually, i wanted user to remain on same page on which error occured.
    According to your reply, i would have to do something like:-
    if (PreviousPage != null && !PreviousPage.IsValid)
    {
    Response.Redirect("PreviousPage.aspx");
    //Response.Write("Wrong...");
    }

    And, i didn't want to do that,
    For now, i have used simple Response.Redirect("NextPage.aspx")
    and used Session variable for the collection i wanted on NextPage.aspx

    Thank you!
    Nutan

    --------------------------------------------------------------------------------------

    "Teemu Keiski" <> wrote in message
    news:...
    > Hi,
    >
    > could you use validation controls to detect these errors? You could also
    > have some script of your own to prevent cross-page postback from happening
    > if it could be detectable from client-side script.
    >
    > In anycase you can check the validity on the target page
    >
    > if (PreviousPage != null && !PreviousPage.IsValid)
    >
    > {
    >
    > Response.Write("Wrong...");
    >
    >
    > }
    >
    >
    > --
    > Teemu Keiski
    > AspInsider, ASP.NET MVP
    > http://blogs.aspadvice.com/joteke
    > http://teemukeiski.net
    >
    >
    >
    >
    >
    > "Nutan" <> wrote in message
    > news:...
    >> Hello,
    >>
    >> I am facing a problem in using PostbackUrl property in asp.net.
    >> I have set value for PostBackUrl property of asp:Button control.
    >> Fine, that it redirects user to another page, allowing me to access all
    >> properties, controls of previous page.
    >>
    >> But problem comes when my current page is having some error and i want to
    >> report these errors to user,
    >> but instead of staying on the same page, it redirects user to another
    >> page.
    >>
    >> How can i stop user to be redirected to another page, when PostbackUrl
    >> property is set.
    >>
    >> Thanx and Regards
    >> Nutan
    >>

    >
    >
    Nutan, May 19, 2008
    #3
  4. Nutan

    Teemu Keiski Guest

    Hi,

    that's why I asked if you could detect the condition in clint-side script,
    because then page would stay the same. Because cross.page postback is
    initiated by client-side script, and page posts directly to the target page,
    and on the server the original page is actually executed if you access
    PreviousPage property (to restore the state where it was) and then the
    target page could access PreviousPage.

    Whole point being that you'd really need to do it client-side scrupt if you
    intend doing it before cross-page postback (of course redirecting or using
    Server.Transfer is other option --> Server.Transfer also populates
    PreviousPage property, see my post:
    http://aspadvice.com/blogs/joteke/a...age-and-PreviousPage.IsCrossPagePostBack.aspx
    )

    --
    Teemu Keiski
    AspInsider, ASP.NET MVP
    http://blogs.aspadvice.com/joteke
    http://teemukeiski.net


    "Nutan" <> wrote in message
    news:...
    > Hello Teemu,
    >
    > Thanks for the reply.
    > Actually, i wanted user to remain on same page on which error occured.
    > According to your reply, i would have to do something like:-
    > if (PreviousPage != null && !PreviousPage.IsValid)
    > {
    > Response.Redirect("PreviousPage.aspx");
    > //Response.Write("Wrong...");
    > }
    >
    > And, i didn't want to do that,
    > For now, i have used simple Response.Redirect("NextPage.aspx")
    > and used Session variable for the collection i wanted on NextPage.aspx
    >
    > Thank you!
    > Nutan
    >
    > --------------------------------------------------------------------------------------
    >
    > "Teemu Keiski" <> wrote in message
    > news:...
    >> Hi,
    >>
    >> could you use validation controls to detect these errors? You could also
    >> have some script of your own to prevent cross-page postback from
    >> happening if it could be detectable from client-side script.
    >>
    >> In anycase you can check the validity on the target page
    >>
    >> if (PreviousPage != null && !PreviousPage.IsValid)
    >>
    >> {
    >>
    >> Response.Write("Wrong...");
    >>
    >>
    >> }
    >>
    >>
    >> --
    >> Teemu Keiski
    >> AspInsider, ASP.NET MVP
    >> http://blogs.aspadvice.com/joteke
    >> http://teemukeiski.net
    >>
    >>
    >>
    >>
    >>
    >> "Nutan" <> wrote in message
    >> news:...
    >>> Hello,
    >>>
    >>> I am facing a problem in using PostbackUrl property in asp.net.
    >>> I have set value for PostBackUrl property of asp:Button control.
    >>> Fine, that it redirects user to another page, allowing me to access all
    >>> properties, controls of previous page.
    >>>
    >>> But problem comes when my current page is having some error and i want
    >>> to
    >>> report these errors to user,
    >>> but instead of staying on the same page, it redirects user to another
    >>> page.
    >>>
    >>> How can i stop user to be redirected to another page, when PostbackUrl
    >>> property is set.
    >>>
    >>> Thanx and Regards
    >>> Nutan
    >>>

    >>
    >>

    >
    >
    Teemu Keiski, May 20, 2008
    #4
    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. ABC
    Replies:
    6
    Views:
    4,008
    Bruce Barker
    Oct 7, 2005
  2. Rob Meade

    ImageButon: PostBackURL

    Rob Meade, Dec 4, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    1,519
    Teemu Keiski
    Dec 4, 2005
  3. bill

    PostBackURL to new window

    bill, Feb 10, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    18,234
  4. osh
    Replies:
    1
    Views:
    5,956
  5. Fabio Mastria
    Replies:
    2
    Views:
    2,538
Loading...

Share This Page