简体   繁体   English

禁用CS页面上的输入类型单选按钮单击,并使用js向用户发送警报?

[英]Disable input type radio button click from cs page and send alert to user using js?

i have a radio button which is disable for managers but enable for otherrs it need to handle from cs page radio button onclick .the code to disable radio from aspx is 我有一个单选按钮,它对经理禁用,但对其他人启用,它需要从cs页面单选按钮onclick处理。禁用aspx单选的代码是

<INPUT type="radio" name="myButton" value="theValue"
onclick="this.checked=false;
alert('Sorry, this option is not for manager!')">

how to do it in cs page i am doing 我正在做的CS页面中如何做

rbtnOpen.Attributes.Add("OnClick", "this.checked=false; alert('Sorry, this option is not available!')");

its working fine and also showing the alert but when but page is refreshing . 它的工作正常,并显示警报,但何时页面刷新。 let say i have 3 stat A,B,C.... for an iten B is selected radio for manager if he clicks A or C is should prompt the alert after closing the alert it should again show B ..in my case its prompting the alert but all the radio button become uncheck 假设我有3个状态A,B,C ....如果一个经理B被选择为经理,如果他单击A或C,则在关闭警报后应该提示警报,它应该再次显示B。提示警报,但所有单选按钮都取消选中

Try this 尝试这个

            <!DOCTYPE html>
            <html>
            <head>
            <script>
            function check()
            {

             alert('Sorry, this option is not available!');
             document.getElementById("b").checked=true;
            }
            </script>
            </head>
            <body>

            A<input type="radio" name="gender" id="a" value="a" onclick="check()"/>
            B<input type="radio" name="gender" id="b" value="b" />
            C<input type="radio" name="gender" id="c" value="c" onclick="check()"/>

            </body>
            </html> 

Why don't you completely disable the control for managers, instead of displaying it as a clickable input? 为什么不完全禁用管理器控件,而不是将其显示为可点击的输入? That way you'd make it even more clear that managers cannot use that option. 这样一来,您将更加清楚经理无法使用该选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在按钮上,单击发送Ajax调用并从aspx.cs(后面的代码)获取值到aspx页面,并将其显示在同一页面的输入字段中 - On button click send Ajax call and get value from aspx.cs(code behind) to aspx page and display it in input field in the same page 使用外部js调用aspx.cs函数(按下按钮) - using external js to call aspx.cs function (on button click) HTML输入类型单选按钮在页面加载时不显示选择 - HTML input type radio button not showing selection on page load 从aspx.cs中的js中删除单选按钮选择的值后,选择的值仍然存在 - after removing radio button selected value from js in aspx.cs selected value presists 如何使用 jquery/javascript 在 asp.net c# 中禁用单选按钮上的链接按钮单击 - How to disable a link button on radio button click in asp.net c# using jquery/javascript 显示新页面,显示单击按钮后的用户输入 - Display new page showing user input upon button click 按钮单击以发送到新页面 - Button Click To Send To New Page 单击按钮将数据从Telerik Grid发送到新选项卡/页面 - Send data from Telerik Grid to new tab/page on button click 使用.cs页面触发html按钮 - Fire html button using .cs page 无法从内容页面访问母版页的<input type =“button”> - Can not access <input type=“button”> of a master page from a content page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM