在用户控件里WebUserControl1.ascx:
public DropDownList DropDownList2
{
get
{
return DropDownList1;
}
set
{
DropDownList1=value;
}
}调用页面中
protected WebUserControl1 testPage;
……
string str=testPage.DropDownList2.SelectedItem.Value;
public DropDownList DropDownList2
{
get
{
return DropDownList1;
}
set
{
DropDownList1=value;
}
}调用页面中
protected WebUserControl1 testPage;
……
string str=testPage.DropDownList2.SelectedItem.Value;
public DropdownList myDropdownList;
2,将此控件放置到aspx页面:
<uc1:WebUserControl1 id="WebUserControl11" runat="server"></uc1:WebUserControl1></form>
3,在aspx.cs代码中InitializeComponent()方法中加入事件挂钩:
this.WebUserControl11.DropDownList1.SelectedIndexChanged += new System.EventHandler(this.DropDownList1_SelectedIndexChanged); //DropDownList1_SelectedIndexChanged方法就是在apsx.cs中处理SelectedIndexChanged事件的代码