本文介绍了查找另一个页面的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在当前页面后面的代码中找到另一个aspx中存在的单选按钮控件?

How can i find a radiobutton control that exists in another aspx, in my current page''s code behind?

推荐答案

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


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





or you can use


<asp:Button ID="Button1" runat="server" Text="test now "

        onclick="Button1_Click2"   />





code behind 


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

}





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


in the the other page 





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

   }


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



如果有帮助,请投票.



Please vote if this helped you then.



这篇关于查找另一个页面的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-08 01:49