Rajan Vachhani Rajan Vachhani - 13 days ago 7
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

There is no readonly property for DropDownList in asp.net

Try using:

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

Or change it at runtime:

DropDownList1.Enabled=false;

and change it's css class as well.

DropDownList1.CssClass = "class";