asp.net 用户控件中的委托事件SelectedIndexChanged

 

YearPicker.ascx

//前台代码(必须添加AutoPostBack="true",否则无效)
<asp:DropDownList ID="ddlYear" runat="server" AutoPostBack="true" onselectedindexchanged="ddlYear_SelectedIndexChanged">
</asp:DropDownList>
<asp:TextBox ID="txtTimeBegin" οnclick="WdatePicker({skin:'whyGreen',dateFmt:'MM-dd',isShowClear:false,readOnly:true})"
runat="server" CssClass="textfield" Width="40px"></asp:TextBox>
至
<asp:TextBox ID="txtTimeEnd" οnclick="WdatePicker({skin:'whyGreen',dateFmt:'MM-dd',isShowClear:false,readOnly:true})"
runat="server" CssClass="textfield" Width="40px"></asp:TextBox>
//后台顶部定义
public delegate void PageChangeEventHandler();
public event PageChangeEventHandler SelectedIndexChanged;
public string txtBegin
{
    set { this.txtTimeBegin.Text = value; }
}
public string txtEnd
{
    set { this.txtTimeEnd.Text = value; }
} 

 

 

 

Tm.aspx

//前台代码
<uc2:YearPicker ID="ucYearPicker" runat="server" />
//后台委托事件
this.ucYearPicker.SelectedIndexChanged += new US.Web.UserControl.YearPicker.PageChangeEventHandler(ucYearPicker_SelectedIndexChanged);
void ucYearPicker_SelectedIndexChanged()
{
    if (this.ucYearPicker.Year == "-1")
    {
        this.ucYearPicker.txtBegin = "";
        this.ucYearPicker.txtEnd = "";
    }
}




 

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页