Rajan Vachhani Rajan Vachhani - 1 year ago 131
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".

Answer Source

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";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download