从Web表单访问用户控件中的事件 [英] Accessing Event in user control from web form
本文介绍了从Web表单访问用户控件中的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含下拉菜单的用户控件.该用户控件放置在Web表单上.现在,我必须使用selectionIndexChanged事件,该事件位于页面的下拉事件中.我该如何解决这个问题?放置帮助
Hi,
I have a User control which contains a drop down. This user control is placed on the web form. Now I have to use selectionIndexChanged event which is there in dropdown events from the page . How can I solve this issue ??? Plase help
推荐答案
如何为ASP中的用户控件处理事件.net页面 [ ^ ]
How to handle event for user control in asp.net page[^]
public partial class Test : System.Web.UI.UserControl
{
public event EventHandler buttonClick;
protected void Button1_Click(object sender, EventArgs e)
{
buttonClick(sender, e);
}
}
Then you can subscribe the event buttonClick at webpage to display the different information .
public partial class Test: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
UserControlID.buttonClick+=new EventHandler(UserControlID_buttonClick);
}
protected void UserControlID_buttonClick(object sender, EventArgs e)
{
Response.Write("hello,I am jack.");
}
}
这篇关于从Web表单访问用户控件中的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文