...

View Full Version : User Input form control - c#



geet40
07-13-2007, 04:15 PM
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


<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


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

Brandoe85
07-13-2007, 05:11 PM
Do you have AutoPostBack set to true on your drop down list?

geet40
07-13-2007, 05:30 PM
no.

Thanks,
that works....



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum