Asp.net Cross Page Post Back issue
-
Dear All, I have two web pages, say SourceWebPage and TargetWebPage, on the TargetWebpage I have a directive like: <%@ PreviousPageType VirtualPath = "~/SourceWebPage.aspx" %> These are the code behand on TargetWebPage Page_Load Event: if (!Page.IsPostBack) { if (Page.PreviousPage != null && Page.PreviousPage.IsCrossPagePostBack) { DateTime reportDate = PreviousPage.DTReportDate; string serialNo = PreviousPage.SerialNo; } else { LoadReportType(); odsSyncSummaryReport.FilterExpression = GetObjDSFillerExpression(); gvSyncSummaryReport.DataSourceID = "odsSyncSummaryReport"; gvSyncSummaryReport.DataBind(); } } else { odsSyncSummaryReport.FilterExpression = GetObjDSFillerExpression(); } there is a link button on SourceWebPage like this: OnClick = "lbSerialNo_Click" PostBackUrl = "~/TargetWebPage.aspx". Both pages are able to be accessed by click on the menu, when I go to SourceWebPage first and then click the link button, it posts back to the TargetWebPage and everything works fine. But the problem is when i go to the TargetWebPage first, it throws an exception. I think i know the problem because the PreviousPage property (SourceWebPage) hasn't been loaded yet, therefor there is no way that the TargetWebPage to get the value from SourceWebPage. What i want to know in here is how do I know whether the TargetWebPage is posted from SourceWebPage or it is posted from Menu. This piece of code doesn't help me at all: if (Page.PreviousPage != null && Page.PreviousPage.IsCrossPagePostBack) I was googling for hours but without any luck, can someone in here shed me a light? Thanks
-
Dear All, I have two web pages, say SourceWebPage and TargetWebPage, on the TargetWebpage I have a directive like: <%@ PreviousPageType VirtualPath = "~/SourceWebPage.aspx" %> These are the code behand on TargetWebPage Page_Load Event: if (!Page.IsPostBack) { if (Page.PreviousPage != null && Page.PreviousPage.IsCrossPagePostBack) { DateTime reportDate = PreviousPage.DTReportDate; string serialNo = PreviousPage.SerialNo; } else { LoadReportType(); odsSyncSummaryReport.FilterExpression = GetObjDSFillerExpression(); gvSyncSummaryReport.DataSourceID = "odsSyncSummaryReport"; gvSyncSummaryReport.DataBind(); } } else { odsSyncSummaryReport.FilterExpression = GetObjDSFillerExpression(); } there is a link button on SourceWebPage like this: OnClick = "lbSerialNo_Click" PostBackUrl = "~/TargetWebPage.aspx". Both pages are able to be accessed by click on the menu, when I go to SourceWebPage first and then click the link button, it posts back to the TargetWebPage and everything works fine. But the problem is when i go to the TargetWebPage first, it throws an exception. I think i know the problem because the PreviousPage property (SourceWebPage) hasn't been loaded yet, therefor there is no way that the TargetWebPage to get the value from SourceWebPage. What i want to know in here is how do I know whether the TargetWebPage is posted from SourceWebPage or it is posted from Menu. This piece of code doesn't help me at all: if (Page.PreviousPage != null && Page.PreviousPage.IsCrossPagePostBack) I was googling for hours but without any luck, can someone in here shed me a light? Thanks
You could check the HTTP_REFERER server variable. Also, please remember to format any code you post using pre tags
I know the language. I've read a book. - _Madmatt
-
You could check the HTTP_REFERER server variable. Also, please remember to format any code you post using pre tags
I know the language. I've read a book. - _Madmatt