default.aspx
<asp:ListBox ID="lstFruits" runat="server" AutoPostBack="True" Height="50px"
OnSelectedIndexChanged="lstFruit_SelectedIndexChanged" ValidationGroup="g1"
Width="195px">
<asp:ListItem>---Select---</asp:ListItem>
<asp:ListItem>Others</asp:ListItem>
<asp:ListItem>Apple</asp:ListItem>
<asp:ListItem>Banana</asp:ListItem>
<asp:ListItem>Orange</asp:ListItem>
<asp:ListItem>Graphes</asp:ListItem>
</asp:ListBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="lstFruits" ValidationGroup="g1" Width="1px" InitialValue="---Select---">*</asp:RequiredFieldValidator><br />
<span style="color: #006600; font-size: 12pt;">(If Other Fruits)<br />
</span>
<asp:TextBox ID="txt
Fruits
" runat="server" Width="142px" Enabled="False"></asp:TextBox><br />default.aspx.cs:
protected void lstFruits_SelectedIndexChanged(object sender, EventArgs e)
{
if ( lstFruits .SelectedItem.Text =="Others")
{
lstFruits .Enabled = true;
lstFruits .Focus();
}
else
{
lstFruits .Enabled = false;
}
}
protected void btnInsert_Click(object sender, EventArgs e)
{
if (lstFruits.SelectedItem.Text == "Others" &&
lstFruits
.SelectedIndex !=0)
jobseeker.Fruits = txt
Fruits
.Text.Trim();else
jobseeker.
Fruits
= lst
Fruits
.SelectedItem.Text.Trim();
}
No comments:
Post a Comment