Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2007
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    User Input form control - c#

    I have two fields in the form.
    one a drop down list and the other text box.
    Depending on the value of the drop down list, the text box should be enabled or disabled.
    I am not able to work it.

    The .aspx

    Code:
    <asp:DropDownList ID="DropDownListURL" runat="server" Font-Size="Small"   OnSelectedIndexChanged= "DropDownListURL_SelectedIndexChanged" >
               <asp:ListItem Value="N">No</asp:ListItem>
               <asp:ListItem Value="Y">Yes</asp:ListItem>
           </asp:DropDownList>
    
    <asp:TextBox ID="addURL" runat="server" Width="233px"></asp:TextBox></td>
    The .aspx.cs

    Code:
    protected void DropDownListURL_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (DropDownListURL.SelectedItem.Value == "Y")
            {
                addURL.Enabled = true;
                addURL.EnableViewState = true;
                
            }
            else if (DropDownListURL.SelectedItem.Value == "N")
            {
                addURL.Enabled = false;
                addURL.EnableViewState = false;
              
            }
        }
    Thanks

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Do you have AutoPostBack set to true on your drop down list?

  • #3
    New Coder
    Join Date
    Jun 2007
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    no.

    Thanks,
    that works....


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •