Dear All,
(ASP.NET USING C# CODING)
I designed one form with the following tools in ASP.NET:
label 1(Select your branch) Dropdownlist 1(Select,MCA,OR&CA)
label 2(MCA) label 3(OR&CA)
Dropdownlist 2(Select,Sem1,sem2) Dropdownlist 3(Select,sem1,sem2,sem3)
here when i select my branch is MCA from DropDownlist1 then the label2 and dropdownlist2 must be visible and when i select my branch is OR&CA then the label 3 and dropdownlist3 must be invisible.
kindly send me codings for this yaar..
I will be very much thankfull to you..
Loading
Vishal GilbilePosted Mar 13, 2013, 10:27 PM
All you need to do is setting the visibility of control on selection of a particular dropdownlist i.e on Selection of dropdownlist value you need to set certain control to visible as true or false. For this you have to make use of DropDownList SelectedIndexChanged Event.
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if(DropDownList1.SelectedItem.Text.Equals("mca",StringComparison.InvariantCultureIgnoreCase))
{
label2.Visibile=DropDownList2.Visible=true;
label3.Visible=DropDownList3.Visible=false;
}
else if(DropDownList1.SelectedItem.Text.Equals("OR&ca",StringComparison.InvariantCultureIgnoreCase))
{
label2.Visibile=DropDownList2.Visible=false;
label3.Visible=DropDownList3.Visible=true;
}
}
Hope that solves your problem.
With Regards,
Vishal Gilbile.
Jonna joPosted Mar 15, 2013, 4:02 AM
Jonna joPosted Mar 15, 2013, 3:59 AM
Satyapriya NayakPosted Mar 13, 2013, 1:06 PM
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace WebApplication17
{
public partial class WebForm5 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label2.Visible = false;
Label3.Visible = false;
DropDownList2.Visible = false;
DropDownList3.Visible = false;
if (!IsPostBack)
{
DropDownList1.Items.Add("Select");
DropDownList1.Items.Add("MCA");
DropDownList1.Items.Add("OR&CA");
DropDownList2.Items.Add("Select");
DropDownList2.Items.Add("Sem1");
DropDownList2.Items.Add("Sem2");
DropDownList3.Items.Add("Select");
DropDownList3.Items.Add("Sem1");
DropDownList3.Items.Add("Sem2");
DropDownList3.Items.Add("Sem3");
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedItem.Text == "MCA")
{
Label2.Visible = true;
DropDownList2.Visible = true;
Label3.Visible = false;
DropDownList3.Visible = false;
}
else if (DropDownList1.SelectedItem.Text == "OR&CA")
{
Label3.Visible = false;
DropDownList3.Visible = false;
Label2.Visible = false;
DropDownList2.Visible = false;
}
else
{
Label2.Visible = false;
Label3.Visible = false;
DropDownList2.Visible = false;
DropDownList3.Visible = false;
}
}
}
}