Without using Jquery.
HTML:
<form id="form1" runat="server">
<div>
<table border="2" cellpadding="5" cellspacing="0">
<tr>
<td>
After SSC
</td>
<td>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Text="Please Select" />
<asp:ListItem Text="Diploma" />
<asp:ListItem Text="FYJC/SYJC" />
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
After Diploma / SYJC
</td>
<td>
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList2_OnSelectedIndexChanged">
<asp:ListItem Text="Please Select" />
<asp:ListItem Text="BSCIT" />
<asp:ListItem Text="BE" />
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
After Graduvation
</td>
<td>
<asp:ListBox ID="ListBox1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ListBox1_OnSelectedIndexChanged">
<asp:ListItem Text="Please Select" />
<asp:ListItem Text="M-Tech" />
<asp:ListItem Text="MSCIT" />
</asp:ListBox>
</td>
</tr>
</table>
</div>
</form>
C#:
protected void DropDownList2_OnSelectedIndexChanged(object sender, EventArgs e)
{
if (this.DropDownList1.SelectedItem.Text == "Please Select")
{
this.DropDownList2.SelectedIndex = 0;
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please select DropDownList1 first')", true);
}
}
protected void ListBox1_OnSelectedIndexChanged(object sender, EventArgs e)
{
if (this.DropDownList2.SelectedItem.Text == "Please Select")
{
this.ListBox1.SelectedIndex = 0;
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please select DropDownList2')", true);
}
}
Thank You.