http://xiangai.taobao.com
http://shop148612228.taobao.com

用户控件在父页面上事件处理

我们想在父页面上获取用户控件中dropdownlist的事件

1.在用户控件Region.ascx中

<asp:DropDownList CssClass="shortSelect required" AutoPostBack="true" ID="ddlCounty" runat="server" OnSelectedIndexChanged="ddlCounty_SelectedIndexChanged"> </asp:DropDownList>

在后台中:

public EventHandler eventSelect;         protected void ddlCounty_SelectedIndexChanged(object sender, EventArgs e)         {             if (this.eventSelect != null)             {                 this.eventSelect(this, e);             }         }

2.在父页面中:

protected void Page_Load(object sender, EventArgs e)         {

llTreeViewMenu.Visible = false;             this.SetRegion1.eventSelect += new EventHandler(UserControl_Clicked);

}

  private void UserControl_Clicked(object sender, System.EventArgs e)         {

llTreeViewMenu.Visible = true;

}

ok 我可以根据dropdownlist下来改变时候根据这个选择的值来在父页面进行左侧菜单的隐藏显示

posted @ 2011-12-31 23:38  万事俱备就差个程序员  阅读(212)  评论(0编辑  收藏  举报

http://xiangai.taobao.com
http://shop148612228.taobao.com
如果您觉得对您有帮助.领个红包吧.谢谢.
支付宝红包
微信打赏 支付宝打赏