隐藏document.all.divID.style.visibility='hidden';
不过autopostback属性就比较麻烦了
通过查看源文件你可以看到
设置该属性会自动给DropDownList1加上onchange="__doPostBack('DropDownList1','')"
这样,就有两个onchange:
onchange="document.all.divID.style.visibility='hidden';"
onchange="__doPostBack('DropDownList1','')"
因而第二个,即AutoPostBack就无效了:(
不过autopostback属性就比较麻烦了
通过查看源文件你可以看到
设置该属性会自动给DropDownList1加上onchange="__doPostBack('DropDownList1','')"
这样,就有两个onchange:
onchange="document.all.divID.style.visibility='hidden';"
onchange="__doPostBack('DropDownList1','')"
因而第二个,即AutoPostBack就无效了:(
DropDownList1.Attributes.clear()
但是根本不起作用
不过即使两个onchange,后面一个也不起作用你可以这样啊,把这个列表的AutoPostBack设为false
然后在需要的时候自己用客户端脚本回送表单
例如:
DropDownList1.Attributes["onchange"] = "javascript:document.all.divID.style.visibility='hidden';__doPostBack('DropDownList1','')";
我也试过,这样会报错:找不到对象,即没有__doPostBack函数
我还试过设为AutoPostBack设为true
然后
onchange="document.all.divID.style.visibility='hidden';__doPostBack('DropDownList1','')"
可以提交了,可一刷新div又恢复原值
楼主你再继续往下走吧
http://expert.csdn.net/Expert/TopicView1.asp?id=940895
if(!Page.IsPostBack)
{
DropDownList1.AutoPostBack = true;
}
else
{
DropDownList1.AutoPostBack = true;
}
然后使用
DropDownList1.Attributes["onchange"] = "document.all.div.style.visibility='hidden'; __doPostBack(DropDownList1,'');";
通过查看源文件你可以看到就只有一个onchange,但是div的属性改变不了。