geet40
07-13-2007, 03: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
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