【求助】控件Disabled后如何重新启用

yingyuebingya 2010-03-30 02:44:56
服务器代码如下:

<asp:CheckBox id=cbQutation runat="server" Enabled="false">
</asp:CheckBox>

如何通过JS使该控件重新启用?
PS:disabled=true 不行
其在前台生成的代码如下:

<span disabled="disabled"><input id="dgOther__ctl3_cbQutation" type="checkbox" name="dgOther:_ctl3:cbQutation" disabled="disabled" /></span>

大家帮忙看下,出出主意哈:)。
...全文
272 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
yingyuebingya 2010-03-30
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 phommy 的回复:]
disabled=""肯定行的
LZ看看清一下IE缓存之类的
[/Quote]
多谢提醒,新建了一个白板的页面,成功启用
考虑了一下,因为是服务器控件会自动在checkbox前加个disabled的span

<span disabled="disabled">...</span>

所以,我刚开始改了后没出效果。

谢谢大家,
结贴了!
phommy 2010-03-30
  • 打赏
  • 举报
回复
disabled=""肯定行的
LZ看看清一下IE缓存之类的
yingyuebingya 2010-03-30
  • 打赏
  • 举报
回复
问题解决了

if(IsAbled)
{
OtherTable.rows[i-1].cells[1].innerHTML = "<FONT face=宋体></FONT>  <span disabled><input id=dgOther__ctl"+i+"_cbQutation type=checkbox name=dgOther:_ctl"+i+":cbQutation disabled /></span>";
}
else
{
OtherTable.rows[i-1].cells[1].innerHTML = "<FONT face=宋体></FONT>  <input id=dgOther__ctl"+i+"_cbQutation type=checkbox name=dgOther:_ctl"+i+":cbQutation checked=true />";
}


//直接拼接Html语句了...

还在测试,希望没有什么后续BUG

yingyuebingya 2010-03-30
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 sandy945 的回复:]
Enabled="false"

不要这样写,如果你希望 是不可用的, 用 js 设置
[/Quote]
明白阿非的意思,用服务器控件是为了DataBind的
阿非 2010-03-30
  • 打赏
  • 举报
回复
Enabled="false"

不要这样写,如果你希望 是不可用的, 用 js 设置

yingyuebingya 2010-03-30
  • 打赏
  • 举报
回复

//removeAttribute() 也用了还是不行
yingyuebingya 2010-03-30
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 gxzh0817 的回复:]
Enable=ture; 不行??
[/Quote]
Enable是服务器端的属性,可以的

我现在想在客户端通过JS改
gxzh0817 2010-03-30
  • 打赏
  • 举报
回复
Enable=ture; 不行??
yingyuebingya 2010-03-30
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 zgke 的回复:]
document.getElementById("dgOther__ctl3_cbQutation").setAttribute("disabled","");
[/Quote]
不起效果,查看源还是

<span disabled="disabled"><input id="dgOther__ctl4_cbQutation" type="checkbox" name="dgOther:_ctl4:cbQutation" disabled="disabled" /></span>
deepmist 2010-03-30
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 zgke 的回复:]
document.getElementById("dgOther__ctl3_cbQutation").setAttribute("disabled","");
[/Quote]
right
zgke 2010-03-30
  • 打赏
  • 举报
回复
document.getElementById("dgOther__ctl3_cbQutation").setAttribute("disabled","");
yingyuebingya 2010-03-30
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 peter200694013 的回复:]
up...
[/Quote]
Thank you!
Peter200694013 2010-03-30
  • 打赏
  • 举报
回复
up...

110,546

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧