怎样时用用户控件中的事件
Posted on 八月 16rd, 2007 由 admin
我创建了一个用户控件,在页面中只有一个dropdownlist,怎样在使用这个控件的页面中使用selectedindexchanged事件??
推荐阅读
网友:chnking
1,在控件中声明dropdownlist时,把访问限制符protected改为public:
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事件的代码


讨论区