0

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.

user3264676
  • 253
  • 5
  • 8
  • 20
  • Just disable the dropdown from client side. – Usman Khalid Feb 26 '14 at 11:07
  • possible duplicate of [How to make html – Asons Feb 26 '14 at 12:24

2 Answers2

0

Try it:

Jquery:

 $(document).ready(function() {
      $("#dropdounid").prop("disabled", true);
 });

OR

 $(document).ready(function() {
      $("#dropdounid").attr("disabled", true);
 });

OR

Javascript

you can disable Asp.net DropDownList using below code in javascript at client side.

document.getElementById('<%=txtActualWindSpeed.ClientID%>').disabled = true;

Edit

you can put this code inside of head tag or body tag.

<head>
  <script>
     document.getElementById('<%=txtActualWindSpeed.ClientID%>').disabled = true;
  </script>
</head>

I hope it will helpful to you.

jsfiddle Demo

Govinda Rajbhar
  • 2,926
  • 6
  • 37
  • 62
0

You can use

$(selector).attr('disabled',true);

jsFiddle

shanish
  • 1,964
  • 12
  • 35
  • 62