ASP.NET 2.0 Cross Page Posting
-
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
-
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
Try
Request.Form["lbl1"]
Regards R.Arockiapathinathan -
Try
Request.Form["lbl1"]
Regards R.ArockiapathinathanHi 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
-
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
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!
-
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!
Thanks CWIZO!!! 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
Hi there, There are two things that you should remember: + The
FindControl
method searchs for a specific control in the current naming container. + TheMasterPage, ContentPlaceHolder
are naming containers. So, if you want to access the label control in the page1, you first need to get reference to theMasterPage
object in the Page1, then look for theContentPlaceHolder
, 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.