Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Asp.net Cross Page Post Back issue

Asp.net Cross Page Post Back issue

Scheduled Pinned Locked Moved ASP.NET
helpquestioncsharpasp-net
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AndieDu
    wrote on last edited by
    #1

    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

    N 1 Reply Last reply
    0
    • A AndieDu

      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

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      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

      A 1 Reply Last reply
      0
      • N Not Active

        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

        A Offline
        A Offline
        AndieDu
        wrote on last edited by
        #3

        Thanks a lot mate, your post does help me and to help the others further, this is the code (in c#) that does the trick: if (Request.ServerVariables["HTTP_REFERER"].EndsWith("xxx.aspx"))

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups