0
我的主頁面中的自定義控件,它可以訪問主頁面嗎?關於ASP.NET中的Web控制範圍的困惑
請幫忙! 這是我的代碼。
namespace TVSSystem
{
public partial class ControlTVS1 : System.Web.UI.UserControl
{
Page abc;
protected void Page_Load(object sender, EventArgs e)
{
abc = this.Page; //Control: I suposse that I can access all controls of my page
}
protected void Image1_Click(object sender, ImageClickEventArgs e)
{
ContentPlaceHolder cph = (ContentPlaceHolder)abc.FindControl("ContentPlacerHolder1");
TextBox txt = (TextBox)cph.FindControl("TextBox1");
Button btn = (Button)cph.FindControl("Button3");
txt.Visible = true;
btn.Visible = true;
}
}
}
已解決。 http://forums.asp.net/t/1000865.aspx/1
我這樣做了,但拋出NullReferenceException異常。 – 2012-04-15 08:39:16
你更精確地做了什麼?你能展示一些代碼嗎?我很難猜測。 – 2012-04-15 08:40:09
現在您可以看到我的代碼。 – 2012-04-15 08:45:43