我正在构建一个模式框作为自定义服务器控件,我想在模态框TargetControlID上有一个属性,指定单击时将显示模式的元素。我给自己定的属性了在模态对话框,并在后面的代码我使用下面的代码块(这是我在几个不同的地方如何从我的自定义服务器控件中访问页面控件?
If (_targetControlId <> "") Then
Dim targetControl As WebControl = Me.Page.FindControl(_targetControlId)
targetControl.Attributes.Add("onclick", "test1();")
targetControl.Attributes.Add("onclick", "test2();")
End If
什么情况是,targetControl总是卷起为NULL已经试过,并导致页面崩溃时,我试图添加属性,我已经双重检查targetControlId的拼写,我指定一个控制是runat =“服务器”。什么是服务器控制正确的方式来它包含的页面上访问其他控件?
感谢,
迈克
您是否在使用MasterPage? – Jim 2009-10-16 19:35:31