Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > PostbackUrl

Reply
Thread Tools

PostbackUrl

 
 
Nutan
Guest
Posts: n/a
 
      05-14-2008
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


 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      05-18-2008
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
 
Nutan
Guest
Posts: n/a
 
      05-19-2008
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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
>>

>
>



 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      05-20-2008
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/ar...ePostBack.aspx
)

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


"Nutan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> 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
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Enable a button via javascript with PostBackUrl set -> the postbackurl doesn't work Fabio Mastria ASP .Net 2 03-04-2008 09:23 AM
PostBackUrl and Retrieving Values from User Controls osh ASP .Net 1 02-25-2006 06:58 PM
PostBackURL to new window bill ASP .Net 3 02-10-2006 03:34 PM
ImageButon: PostBackURL Rob Meade ASP .Net 1 12-04-2005 11:43 AM
PostBackUrl cannot work for file link. ABC ASP .Net 6 10-07-2005 06:05 PM



Advertisments