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 2.0 Cross Page Posting

ASP.NET 2.0 Cross Page Posting

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-nettutorialquestion
6 Posts 4 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.
  • S Offline
    S Offline
    Subrahmanyam K
    wrote on last edited by
    #1

    Hi, I have a problem in accessing a control of previous page using ASP.NET Cross page posting. The following is the Scenario: I have two pages say Page1 and Page2 which both have the same Master page (Master1). I have set the PostBackURL property for Page1 as "Page2". I have a panel control "Pnl1" which contains a label "lbl1" on Page1. Now, I would like to access the label control "lbl1" of Page1 in Page2 using Cross page posting functionality. When I use "this.PreviousPage" in Page2, I could able to find the controls on the Master page but not the controls (Pnl1 and lbl1) on Page1. How to find the label control "lbl1" which is on Page1 in Page2? Thanks in advance for some help.... Subrahmanyam K

    R M 2 Replies Last reply
    0
    • S Subrahmanyam K

      Hi, I have a problem in accessing a control of previous page using ASP.NET Cross page posting. The following is the Scenario: I have two pages say Page1 and Page2 which both have the same Master page (Master1). I have set the PostBackURL property for Page1 as "Page2". I have a panel control "Pnl1" which contains a label "lbl1" on Page1. Now, I would like to access the label control "lbl1" of Page1 in Page2 using Cross page posting functionality. When I use "this.PreviousPage" in Page2, I could able to find the controls on the Master page but not the controls (Pnl1 and lbl1) on Page1. How to find the label control "lbl1" which is on Page1 in Page2? Thanks in advance for some help.... Subrahmanyam K

      R Offline
      R Offline
      RSArockiam
      wrote on last edited by
      #2

      Try Request.Form["lbl1"] Regards R.Arockiapathinathan

      S 1 Reply Last reply
      0
      • R RSArockiam

        Try Request.Form["lbl1"] Regards R.Arockiapathinathan

        S Offline
        S Offline
        Subrahmanyam K
        wrote on last edited by
        #3

        Hi Arockiapathinathan, I'm sorry. I couldn't get my problem solved with Request.Form["lbl1"]. I need to retrieve the information from a label which is on Page1. Thank you once again. Subrahmanyam K

        C 1 Reply Last reply
        0
        • S Subrahmanyam K

          Hi Arockiapathinathan, I'm sorry. I couldn't get my problem solved with Request.Form["lbl1"]. I need to retrieve the information from a label which is on Page1. Thank you once again. Subrahmanyam K

          C Offline
          C Offline
          CWIZO
          wrote on last edited by
          #4

          Labels don't get posted over the request. I don't know how cross-posting works in 2.0 (I have jsut started working with it) but I imagine that if you post your data from page1 to page2 you will not be able to access proeprties of page1 on page2, becouse it is a totaly seperate request... I think the best way is to have a hidden inpult filed on the page1 and then read the contents on page2 with: Request.Form["nameOfHiddenField"] Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!

          S 1 Reply Last reply
          0
          • C CWIZO

            Labels don't get posted over the request. I don't know how cross-posting works in 2.0 (I have jsut started working with it) but I imagine that if you post your data from page1 to page2 you will not be able to access proeprties of page1 on page2, becouse it is a totaly seperate request... I think the best way is to have a hidden inpult filed on the page1 and then read the contents on page2 with: Request.Form["nameOfHiddenField"] Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!

            S Offline
            S Offline
            Subrahmanyam K
            wrote on last edited by
            #5

            Thanks CWIZO!!! Subrahmanyam K

            1 Reply Last reply
            0
            • S Subrahmanyam K

              Hi, I have a problem in accessing a control of previous page using ASP.NET Cross page posting. The following is the Scenario: I have two pages say Page1 and Page2 which both have the same Master page (Master1). I have set the PostBackURL property for Page1 as "Page2". I have a panel control "Pnl1" which contains a label "lbl1" on Page1. Now, I would like to access the label control "lbl1" of Page1 in Page2 using Cross page posting functionality. When I use "this.PreviousPage" in Page2, I could able to find the controls on the Master page but not the controls (Pnl1 and lbl1) on Page1. How to find the label control "lbl1" which is on Page1 in Page2? Thanks in advance for some help.... Subrahmanyam K

              M Offline
              M Offline
              minhpc_bk
              wrote on last edited by
              #6

              Hi there, There are two things that you should remember: + The FindControl method searchs for a specific control in the current naming container. + The MasterPage, ContentPlaceHolder are naming containers. So, if you want to access the label control in the page1, you first need to get reference to the MasterPage object in the Page1, then look for the ContentPlaceHolder, and finally try to access the Label control. The sample code looks something like:

              MasterPage masterPage = PreviousPage.Controls[0] as MasterPage;
              ContentPlaceHolder holder1 = masterPage.FindControl("ContentPlaceHolder1") as ContentPlaceHolder;
              Label lbl = holder1.FindControl("Label1") as Label;

              In addition, you can also expose the value of the label control as a public property of the page1 so that you can access in the target page page2.

              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