[英]How to block User from changing DropDownList value using javascript in asp.net?
Hi I have a dropdownlist, I am selecting its valus from server side code. 嗨,我有一个下拉列表,我从服务器端代码中选择其值。 I don't want to allow user to change it. 我不想允许用户更改它。 Means He must not be able to change it neither by mouse click and not by keyboard. 表示他一定不能通过鼠标单击或键盘更改。 I want to handle it from Client Side. 我想从客户端处理它。 Please suggest only javascript methods. 请仅建议使用javascript方法。
Try it: 试试吧:
Jquery: jQuery:
$(document).ready(function() {
$("#dropdounid").prop("disabled", true);
});
OR 要么
$(document).ready(function() {
$("#dropdounid").attr("disabled", true);
});
OR 要么
Javascript Java脚本
you can disable Asp.net DropDownList
using below code in javascript at client side. 您可以在客户端使用javascript中的以下代码禁用Asp.net DropDownList
。
document.getElementById('<%=txtActualWindSpeed.ClientID%>').disabled = true;
Edit 编辑
you can put this code inside of head tag or body tag
. 您可以将此代码放在head tag or body tag
。
<head>
<script>
document.getElementById('<%=txtActualWindSpeed.ClientID%>').disabled = true;
</script>
</head>
I hope it will helpful to you. 希望对您有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.