PostbackUrl

N

Nutan

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
 
T

Teemu Keiski

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...");


}
 
N

Nutan

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

--------------------------------------------------------------------------------------
 
T

Teemu Keiski

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
)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top