Click here to Skip to main content
15,921,531 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can i find a radiobutton control that exists in another aspx, in my current page's code behind?
Posted

1. set the PostBackUrl property of the Button to the New Page  

XML
<asp:button id="Button1" runat="server" text="test now " postbackurl="~/Default5.aspx" xmlns:asp="#unknown" />


or you can use

XML
<asp:Button ID="Button1" runat="server" Text="test now "
        onclick="Button1_Click2"   />


code behind 

C#
protected void Button1_Click2(object sender, EventArgs e)
{
          Server.Transfer("Default5.aspx");
 
}


C#
Note :         Response.Redirect("Default5.aspx"); will raise 
Error Object reference not set to an instance of an object.

in the the other page 


C#
protected void Page_Load(object sender, EventArgs e)
   {
// this is page Default5
       if (!IsPostBack)
       {
           Button btn = ((Button)PreviousPage.FindControl("Button1"));
           Button1.Text = btn.Text;
       }

   }
 
Share this answer
 
Comments
kham sokheng 27-Mar-12 0:36am    
Hi,
I have try this, but it work only when i open new page in the existing page of the browser, if i open it in two different page on the same time in browser it doesn't work. Do you have any idea about this please help!

Thank
If you redirect to current page with "Response.Redirect" or "PostBackUrl" then below code should work. But If you starts with Page1.aspx and redirect to Page2.aspx and then redirect to Page3.aspx then you can not find control which placed on Page1.aspx. You can find control only placed with Page2.aspx.

C#
RadioButton rb = (RadioButton)PreviousPage.FindControl("RadioBtn1");


Please vote if this helped you then.
 
Share this answer
 
Comments
deepak thomas 6-Oct-10 6:05am    
i am opening the page in a radwindow(pop -up) of telerik controls.if so will i get the control?
If the two page is cross page then you can get the value of the control. Otherwise you have to store the value of the control in session or others.
 
Share this answer
 
 
Share this answer
 
Comments
deepak thomas 6-Oct-10 5:58am    
getting error

Object reference not set to an instance of an object

i am pasting the code below which i tried

protected void Page_Load(object sender, EventArgs e)
{
CheckBox c = (CheckBox)PreviousPage.FindControl("gendoccheck1");
}
deepak thomas 6-Oct-10 5:59am    
i am opening the page in a radwindow(pop -up) of telerik controls.if so will i get the control?
m@dhu 6-Oct-10 6:13am    
Is rad window present in a different page from page you are redirecting?
deepak thomas 6-Oct-10 6:18am    
yes
deepak thomas 6-Oct-10 6:21am    
i am opening the new page in radwindow using this javascript on OnClientClick of a button in test0.aspx page

function OpenGenDocsWindow() {

var wnd = window.radopen("test1.aspx?Id=" + ID, null);
wnd.setSize(400, 400);
return false;


}
Adding to what other responder already said, I would suggest you to read this article on MSDN - Redirecting Users to Another Page[^].

You will understand the fundamentals of redirection and in which cases previous page values can be accessed in asp.net.

Hope this helps!
 
Share this answer
 
v2
Comments
deepak thomas 6-Oct-10 6:11am    
i am opening the page in a radwindow(pop -up) of telerik controls.if so will i get the control?
Ankur\m/ 6-Oct-10 6:31am    
I am sorry, I haven't used Telerik controls and I have no idea about rad-window. So I won't be able to help much with this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900