ASP.NET 控件不用Disabled实现ReadOnly的效果,即字体不变灰色。
来源:互联网 发布:centos latex 编辑:程序博客网 时间:2024/06/06 03:21
参考引用:
HTML中Select不用Disabled实现ReadOnly的效果-javascript技巧
<select onbeforeactivate="return false" onfocus="this.blur()" onmouseover="this.setCapture()" onmouseout="this.releaseCapture()"> <option>1</option></select>
同理,在ASP.NET中的应用
在asp.net页面中针对RadioButtonLis、RadioButton、DropDownList、HtmlSelect等控件标签中添加onmouseover="this.setCapture()" onmouseout="this.releaseCapture()"即可(字体颜色也可以直接设置或通过css设置了)。
如:
<asp:RadioButtonList ID="rdoP_Type" runat="server" RepeatColumns="2" RepeatLayout="Flow" onmouseover="this.setCapture()" onmouseout="this.releaseCapture()" ForeColor="#FF9966">
<asp:ListItem Value="Y">是 </asp:ListItem>
<asp:ListItem Value="N">否 </asp:ListItem>
</asp:RadioButtonList>
在程序中,可以这样添加:
以VB.NET为例:
rdoP_Type.Attributes.Add("onmouseover","this.setCapture()")
rdoP_Type.Attributes.Add("onmouseout","this.releaseCapture()")
分别在IE和FF浏览器下测试,发现IE测试没问题,但是FF并不支持(setCapture和releaseCapture,FF有自己的),再加个属性试试,变成这样
rdoP_Type.Attributes.Add("onmouseover","this.setCapture()") ’IE支持,FF不支持
rdoP_Type.Attributes.Add("onclick","return false") ‘让FF支持
多个控件的情况下,可以通过遍历设置属性:
For Each t As Control In ControlsIf TypeOf (t) Is RadioButtonList Then
Dim t1 As RadioButtonList = CType(t, RadioButtonList)
t1.Attributes.Add("onmouseover","this.setCapture()")
t1.Attributes.Add("onmouseout","this.releaseCapture()")
t1.Attributes.Add("onclick","return false")
Next
在此之前,试过其他方法,不太理想,在此记录一下,以备需要时参考:
t1.Attributes.Add("style", "color:blue") 'FF支持,IE不兼容
t1.Attributes.Add("onclick", "return false")
t1.Attributes.Add("onclick", "this.checked=!this.checked") ’
t1.Attributes.Add("onclick", " if(rdoP_Type_0.checked) rdoP_Type_1.checked=!rdoP_Type_1.checked;") ‘有些效果,但需要继续完善判定方法。
- ASP.NET 控件不用Disabled实现ReadOnly的效果,即字体不变灰色。
- HTML中Select不用Disabled实现ReadOnly的效果
- HTML中Select不用Disabled实现ReadOnly的另类实现
- HTML中Select不用Disabled实现ReadOnly的另类实现
- ASP.NET 2.0中TextBox服务器控件的ReadOnly和Disabled属性
- ASP.NET 2.0中TextBox服务器控件的ReadOnly和Disabled属性
- ASP.NET 2.0中TextBox服务器控件的ReadOnly和Disabled属性
- ASP.NET 2.0中TextBox服务器控件的ReadOnly和Disabled属性
- ASP.NET 2.0中TextBox服务器控件的ReadOnly和Disabled属性
- ASP.NET 2.0中TextBox服务器控件的ReadOnly和Disabled属性
- ASP.NET 2.0中TextBox服务器控件的ReadOnly和Disabled属性
- 解决TextBox的Disabled字体为灰色的问题
- (转)解决Asp.net中文本框控件(TextBox)readonly或disabled时内容无法POST到服
- 如何实现JSP页面控件的不可编辑——disabled readonly
- ASP.NET JS设置控件的DISABLED的问题
- asp.net 的 textbox控件怎么设置readonly属性
- ASP.NET中将TextBox控件的Readonly…
- asp.net 文本控件readonly与disable的区别
- 将C++builder中的类成员函数当作windows回调函数
- sybase字段属性,identity,设置跳跃值,手工插入自增初始值
- 运算符%
- 19~20日学习总结
- mysql字段值自动更新时间
- ASP.NET 控件不用Disabled实现ReadOnly的效果,即字体不变灰色。
- win7 优化处理
- SVN版本冲突文件说明 和 解决办法
- FontAwesome-用TextView显示图片
- Eclipse新建类向导
- WaitForSingleObject函数的使用
- C++全局变量的声明与定义的详解
- SuiShenJi项目_登录界面
- 深入理解java异常处理机制