本文介绍了母版页事件应该更改内容页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用VB.Net
我在主页上有一个下拉列表,我需要在内容页面中激活其selectedindexchange事件,就好像它是对内容页面的控制一样。我想将此事件传递给内容页面。可能吗。
感谢所有
I am using VB.Net
I have a dropdown list on masterpage, I need to fire its selectedindexchange event in content pages as if its a control of content page. I want to pass this event to content page. Is it possible.
Thanks all
推荐答案
protected void Page_Load(object sender, EventArgs e)
{
DropDownList drp = (DropDownList)Page.Master.FindControl("drpDownlist");
drp.SelectedIndexChanged+=new EventHandler(drp_SelectedIndexChanged);
}
void drp_SelectedIndexChanged(object sender, EventArgs e)
{
}
只需在您的内容页面中写下此代码即可完成。
just write this code in your content page and it is done.
Public Event SelectedIndexChange(ByVal sender As Object, ByVal e As System.EventArgs)
Protected Sub drpmember_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles drpmember.SelectedIndexChanged
RaiseEvent SelectedIndexChange(Me, e)
End Sub
在内容页面的PreInit事件中
In PreInit event of content page
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
Dim drp As DropDownList = DirectCast(Page.Master.FindControl("drpmember"), DropDownList)
AddHandler Master.SelectedIndexChange, AddressOf DelegateName
End Sub
In内容页面
In Content page
Protected Sub DelegateName(sender As Object, e As System.EventArgs)
''' Your Logic
End Sub
这篇关于母版页事件应该更改内容页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!