Rajan Vachhani Rajan Vachhani - 1 month ago 21
C# Question

How to make Dropdownlist readonly in C#

I am using

TextBox.ReadOnly = false;

for readonly.

How can i fix it on DropDownList?

I use Enabled = false properties like...

TextBox.Enabled = false;
DropDownList.Enabled = false;

but, after that css class not call in this both control at run-time.

Please give me any properties like "ReadOnly".


There is no readonly property for DropDownList in asp.net

Try using:

  <asp:DropDownList ID="DropDownList1" runat="server" Enabled="False">

Or change it at runtime:


and change it's css class as well.

DropDownList1.CssClass = "class";