Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Enabling AJAX ComboBox ?

Enabling AJAX ComboBox ?

Scheduled Pinned Locked Moved ASP.NET
questionsysadminhelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    paper67
    wrote on last edited by
    #1

    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" />&nbsp
        <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

    N R 2 Replies Last reply
    0
    • P paper67

      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" />&nbsp
          <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

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      You 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

      1 Reply Last reply
      0
      • P paper67

        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" />&nbsp
            <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

        R Offline
        R Offline
        Rutvik Dave
        wrote on last edited by
        #3

        This is because you are not using an UpdatePanel. add an UpdatePanel on the page and put everything inside except ScirptManager . and it will work. and also use the scriptmanager instead of toolkitscriptmanager. if you want to do this without AJAX for testing then add Response.Redirect("~\ThisPage.aspx"); after you set the combobox enable true or false, and you dont have to click twice to enable or disable it.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups