后台
//定义公共变量
public string dropIsSmokeClientID ; //(DroptDownList)
public string txtSmokeAgeClientID ; //(Textbox)
//给变量赋值
dropIsSmokeClientID = dropIsSmoke.ClientID;
txtSmokeAgeClientID = txtSmokeAge.ClientID;
//给服务器控件增加脚本
dropIsSmoke.Attributes.Add("onchange", "return IsSmoke()");
前台脚本
<script language="javascript">
function IsSmoke()
{
//前台找服务器控件
var SmokeValue=document.getElementById('<%=dropIsSmokeClientID %>');
var SmokeAge=document.getElementById('<%=txtSmokeAgeClientID %>');
if(SmokeValue.value=="1")
{
SmokeAge.disabled=false;
}
else
{
SmokeAge.disabled=true;
}
}
</script>