I have a ASP dropdown list which is designed with bootstrap. I have to enable another dropdown on an list item named "Others".
The Drop-down control which needs to be enabled is "ddlotheritem" on selectedindexchanged of "ddlitemtype" is written as
<div class="form-group">
<label>Item Type
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*" ForeColor="Red" Font-Size="Large" Font-Bold="true"
ControlToValidate="ddlitemtype" Display="Dynamic" InitialValue="Select" ValidationGroup="textboxes"></asp:RequiredFieldValidator>
</label>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="ddlitemtype" class="form-control" runat="server" ValidationGroup="textboxes"
EnableViewState="true" AutoPostBack="true" ViewStateMode="Enabled"
OnSelectedIndexChanged="ddlitemtype_SelectedIndexChanged">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div class="form-group">
<label>Others(Type)</label>
<asp:DropDownList ID="ddlotheritem" class="form-control" runat="server" ValidationGroup="textboxes" disabled></asp:DropDownList>
</div>
My problems is as follows.
1) As it is bootstrap design, if I am making Enabled="false" to "ddlotheritem" , the bootstrap designed is gone and a normal ASP dropdown without any design will come. When I add disabled to the tag as above code written, the design is working correctly as disabled text box. If I remove this 'disabled' tag and put Enable="false" in page load also, same thing happens i.e. without a design simple ASP dropdown which I don't want.
However, if this follows, I could not change the control to enabled on the backend code. The code I have written is
protected void ddlitemtype_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlitemtype.SelectedItem.Text.ToUpper() == "OTHERS")
{
ddlotheritem.Attributes["enabled"] = "enabled";
ddlotheritem.Items.Add("text");
}
else
{
ddlotheritem.Attributes["disabled"] = "disabled";
}
}
How can I enable/disable the dropdown box "ddlotheritem" without any design change in Bootstrap on click of the Value "Others" of the dropdown "ddlitemtype" ?
To be noted that this page where this dropdown exists is a content page of a Master.
What I have tried:
As it is bootstrap design, if I am making Enabled="false" to "ddlotheritem" , the bootstrap designed is gone and a normal ASP dropdown without any design will come. When I add disabled to the tag as above code written, the design is working correctly as disabled text box. If I remove this 'disabled' tag and put Enable="false" in page load also, same thing happens i.e. without a design simple ASP dropdown which I don't want.