Click here to Skip to main content
15,038,345 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
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

C#
<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"); // for testing adding a value
        }
        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.
Posted
Updated 28-May-21 19:04pm

1 solution

hi. did u find any solution for this ? i too am facing the same prob.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900