Enabling AJAX ComboBox ?
-
Hi, I gave the follow code snippet :
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" /> <div> <asp:ComboBox ID="ComboBox1" runat="server"> <asp:ListItem Text="Item1" Selected="True" /> <asp:ListItem Text="Item2" /> <asp:ListItem Text="Item3" /> <asp:ListItem Text="Item4" /> </asp:ComboBox><br /><br /> <asp:Button ID="EnableButton" runat="server" Text="Enable" onclick="EnableButton\_Click" />  <asp:Button ID="DisableButton" runat="server" Text="Disable" onclick="DisableButton\_Click" />
With code behind :
protected void EnableButton_Click(object sender, EventArgs e) { ComboBox1.Enabled = true; } protected void DisableButton_Click(object sender, EventArgs e) { ComboBox1.Enabled = false; }
Why do I have to press the "Enable" button twice to enable a disabled ComboBox ? How can I solve the problem ? tia -
Hi, I gave the follow code snippet :
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" /> <div> <asp:ComboBox ID="ComboBox1" runat="server"> <asp:ListItem Text="Item1" Selected="True" /> <asp:ListItem Text="Item2" /> <asp:ListItem Text="Item3" /> <asp:ListItem Text="Item4" /> </asp:ComboBox><br /><br /> <asp:Button ID="EnableButton" runat="server" Text="Enable" onclick="EnableButton\_Click" />  <asp:Button ID="DisableButton" runat="server" Text="Disable" onclick="DisableButton\_Click" />
With code behind :
protected void EnableButton_Click(object sender, EventArgs e) { ComboBox1.Enabled = true; } protected void DisableButton_Click(object sender, EventArgs e) { ComboBox1.Enabled = false; }
Why do I have to press the "Enable" button twice to enable a disabled ComboBox ? How can I solve the problem ? tiaYou don't have an ajax combobox. Just by placing a scriptmanager on the page does not automagically make it ajax. Enabling and disabling controls can easily be accomplished on the client-side with javascript.
I know the language. I've read a book. - _Madmatt
-
Hi, I gave the follow code snippet :
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" /> <div> <asp:ComboBox ID="ComboBox1" runat="server"> <asp:ListItem Text="Item1" Selected="True" /> <asp:ListItem Text="Item2" /> <asp:ListItem Text="Item3" /> <asp:ListItem Text="Item4" /> </asp:ComboBox><br /><br /> <asp:Button ID="EnableButton" runat="server" Text="Enable" onclick="EnableButton\_Click" />  <asp:Button ID="DisableButton" runat="server" Text="Disable" onclick="DisableButton\_Click" />
With code behind :
protected void EnableButton_Click(object sender, EventArgs e) { ComboBox1.Enabled = true; } protected void DisableButton_Click(object sender, EventArgs e) { ComboBox1.Enabled = false; }
Why do I have to press the "Enable" button twice to enable a disabled ComboBox ? How can I solve the problem ? tiaThis is because you are not using an
UpdatePanel
. add anUpdatePanel
on the page and put everything inside exceptScirptManager
. and it will work. and also use the scriptmanager instead of toolkitscriptmanager. if you want to do this without AJAX for testing then addResponse.Redirect("~\ThisPage.aspx");
after you set the combobox enable true or false, and you dont have to click twice to enable or disable it.