设置允许通过CSS /禁用单选按钮 [英] setting Radio Button enabled/disabled via CSS

查看:1099
本文介绍了设置允许通过CSS /禁用单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法,使启用/禁用(未选中/取消)通过CSS一个单选按钮?

我有需要切换客户端上的一些单选按钮,这样的值可以在服务器上读取,但设置已启用属性设置为假,然后通过JavaScript客户端上的改变,这似乎$ P $从它被开启后回发的单选按钮的任何变化pvent我。

请参阅: ASP.NET没有看到单选按钮值的变化

有人建议我用control.style.add(禁用,真)来代替,但是这似乎并没有禁用的单选按钮我。

谢谢!


解决方案

要尽我所知的CSS可以在不影响应用程序的功能。它只能影响显示。因此,尽管你可以用CSS隐藏(显示:无),你无法禁用它。

你可以做的是用JavaScript来禁用它的页面加载。有几个方法可以做到这一点,但一个简单的方法是做类似

<$p$p><$c$c><script>document.getElementById('<%=CONTROLID%>').disabled=true;</script>

和投入,在您的.aspx文件在body标签下方的顶部。

Is there a way to make a Radio Button enabled/disabled (not checked/unchecked) via CSS?

I've need to toggle some radio buttons on the client so that the values can be read on the server, but setting the 'enabled' property to 'false' then changing this on the client via javascript seems to prevent me from posting back any changes to the radio button after it's been enabled.

See: ASP.NET not seeing Radio Button value change

It was recommended that I use control.style.add("disabled", "true") instead, but this does not seem to disable the radio button for me.

Thanks!

解决方案

To the best of my knowledge CSS cannot affect the functionality of the application. It can only affect the display. So while you can hide it with css (display:none) you can't disable it.

What you could do would be to disable it on page load with javascript. There are a couple ways to do this but an easy way would be to do something like

<script>document.getElementById('<%=CONTROLID%>').disabled=true;</script>

and put that in your .aspx file at the top below the body tag.

这篇关于设置允许通过CSS /禁用单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆