能否在Page_load中控制HtmlInputButton的Disabled
HTML页面里有个
<input type= "button " id= "btAdd " onclick= "addUrl(); " value= "新增信息 " >
------
代码
protected System.Web.UI.HtmlControls.HtmlInputButton btAdd;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
string privilege= Session[ "privilege "].ToString() ;
if (privilege.IndexOf( "1 ")!=-1)
{
this.btAdd.Attributes.Add( "disabled ", " ");
}
else
{
this.btAdd.Attributes.Add( "disabled ", "disabled ");
}
}
运行后,提示这句错误
this.btAdd.Attributes.Add( "disabled ", "disabled ");
System.NullReferenceException:
未将对象引用设置到对象的实例。
请问各位大虾怎么错误的啊
------解决方案--------------------没有runat= "server "
------解决方案--------------------按钮加属性runat= "server "