IsCrossPostBack always return false

L

Lore

I've been trying for a while, but unfortunately I can't get a
solutions, neighter I was able to find it in google.

In the CrossPostBack referred page the property IsCrossPostBack is
always set to false, while it should be set to true if the
CrossPostBack occured: is there anybody who can explain me why?

Thanks,
Lorenzo
 
T

Teemu Keiski

Hi,

usage of IsCrossPagePostBack is a bit weird. You don't check it from Page
but from PreviousPage property.

Say on page1.aspx you have

<asp:Button ID="Button1" runat="server" Text="Button"
PostBackUrl="page2.aspx" />

And on page2.aspx in code

If Not Page.PreviousPage Is Nothing Then

If PreviousPage.IsCrossPagePostBack Then
Response.Write("It is a cross-page postback")
End If
'Essentially this means that IsCrossPagePostBack property is
sort of clumsy
'If PreviousPage property is non-null, that's already enough to
know it's a cross-page post
End If

If you use C# then it's just checking if(PreviousPage != null){...} and so
on
 
L

Lorenzo

Thank you very much.

Lorenzo
Teemu Keiski said:
To add,

it's essentially that source page's IsCrossPagePostBack is true. Reason is
that posting to second page also invokes the original posting page, and
there you might need the info if it's participating a cross-page post or
not.

Of course PreviousPage could be non-null when ttere's also
Server.Transfer. See:
http://msdn2.microsoft.com/en-us/library/ms178141.aspx
http://msdn2.microsoft.com/en-US/library/ms178139.aspx


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

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top