By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,853 Members | 842 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,853 IT Pros & Developers. It's quick & easy.

Handling events generated by a Master Page in a content placeholde

P: n/a
I have a problem, I have an event declared in a Master Page, and I want to
use in a Content Page holder of a Content Page. When I want to create the
method to handle the event, I can njot reference the Master Page event, in
its place IntelliSense shows me a Delegate Sub EventHandler. I am new with
events managements, so any help and guiadance will be appreciated.

Federico
Jan 16 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
1- In the content page you need to get a reference to the master page like
this:
<%@ MasterType virtualPath="~/MasterPage.master"%>

http://msdn2.microsoft.com/en-us/library/c8y19k6h.aspx

2- Assuming that the master page raises and event (let's call it
MasterPageEvent1 that has a delegate named MyEventHandler) then you can wire
up an event handler in the content page like this:

Master.MasterPageEvent1+= new MyEventHandler(Master_MasterPageEvent1);

3- Write a function:
void Master_MasterPageEvent1(object sender, EventArgs e)
{
//steps within handling the event
}
For more detail on raising and consuming events:
http://msdn2.microsoft.com/en-us/library/9aackb16.aspx
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Federico" wrote:
I have a problem, I have an event declared in a Master Page, and I want to
use in a Content Page holder of a Content Page. When I want to create the
method to handle the event, I can njot reference the Master Page event, in
its place IntelliSense shows me a Delegate Sub EventHandler. I am new with
events managements, so any help and guiadance will be appreciated.

Federico

Jan 16 '06 #2

P: n/a
I´m developing using VB 2005, I can not view the public event declarated in
the master page, from the content page, so i'm unable to wire up the event
with the handler.
Here is the source code from MasterPage

Partial Class MasterPage
Inherits System.Web.UI.MasterPage

Event event1(ByVal sender As Object, ByVal e As EventArgs)

Protected Sub guardarImageButton_Click(ByVal sender As Object, ByVal e
As System.Web.UI.ImageClickEventArgs) Handles guardarImageButton.Click
RaiseEvent event1(Me, e)
End Sub

End Class

Public Delegate Sub ManejadorEvento(ByVal sender As Object, ByVal e As
EventArgs)

.....and here the code of content page

artial Class _Default
Inherits System.Web.UI.Page

Public Sub metodo()

End Sub

Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init
AddHandler Master.event1, AddressOf metodo ' this is the wrong line
End Sub
End Class

The error reported is:"'event1' is not an event of 'System.Web.UI.MasterPage'.

Please give me an example in VB 2005

Thanks

"Phillip Williams" wrote:
1- In the content page you need to get a reference to the master page like
this:
<%@ MasterType virtualPath="~/MasterPage.master"%>

http://msdn2.microsoft.com/en-us/library/c8y19k6h.aspx

2- Assuming that the master page raises and event (let's call it
MasterPageEvent1 that has a delegate named MyEventHandler) then you can wire
up an event handler in the content page like this:

Master.MasterPageEvent1+= new MyEventHandler(Master_MasterPageEvent1);

3- Write a function:
void Master_MasterPageEvent1(object sender, EventArgs e)
{
//steps within handling the event
}
For more detail on raising and consuming events:
http://msdn2.microsoft.com/en-us/library/9aackb16.aspx
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Federico" wrote:
I have a problem, I have an event declared in a Master Page, and I want to
use in a Content Page holder of a Content Page. When I want to create the
method to handle the event, I can njot reference the Master Page event, in
its place IntelliSense shows me a Delegate Sub EventHandler. I am new with
events managements, so any help and guiadance will be appreciated.

Federico

Jan 17 '06 #3

P: n/a
The link I posted previously has an example in VB that can guide you:
http://msdn2.microsoft.com/en-us/library/9aackb16.aspx

Briefly you needed to modify your code to look like this:

Public Delegate Sub MasterPageEventHandler1(sender As Object, e As
System.Web.UI.ImageClickEventArgs)

Partial Class MasterPage
Inherits System.Web.UI.MasterPage

Public Event1 As MasterPageEventHandler1
Protected Sub guardarImageButton_Click(ByVal sender As Object, ByVal e
As System.Web.UI.ImageClickEventArgs) Handles guardarImageButton.Click
RaiseEvent event1(Me, e)
End Sub

End Class

Then In the content page you need to get a reference to the master page like
this:
<%@ MasterType virtualPath="~/MasterPage.master"%>

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Federico" wrote:
I´m developing using VB 2005, I can not view the public event declarated in
the master page, from the content page, so i'm unable to wire up the event
with the handler.
Here is the source code from MasterPage

Partial Class MasterPage
Inherits System.Web.UI.MasterPage

Event event1(ByVal sender As Object, ByVal e As EventArgs)

Protected Sub guardarImageButton_Click(ByVal sender As Object, ByVal e
As System.Web.UI.ImageClickEventArgs) Handles guardarImageButton.Click
RaiseEvent event1(Me, e)
End Sub

End Class

Public Delegate Sub ManejadorEvento(ByVal sender As Object, ByVal e As
EventArgs)

....and here the code of content page

artial Class _Default
Inherits System.Web.UI.Page

Public Sub metodo()

End Sub

Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init
AddHandler Master.event1, AddressOf metodo ' this is the wrong line
End Sub
End Class

The error reported is:"'event1' is not an event of 'System.Web.UI.MasterPage'.

Please give me an example in VB 2005

Thanks

"Phillip Williams" wrote:
1- In the content page you need to get a reference to the master page like
this:
<%@ MasterType virtualPath="~/MasterPage.master"%>

http://msdn2.microsoft.com/en-us/library/c8y19k6h.aspx

2- Assuming that the master page raises and event (let's call it
MasterPageEvent1 that has a delegate named MyEventHandler) then you can wire
up an event handler in the content page like this:

Master.MasterPageEvent1+= new MyEventHandler(Master_MasterPageEvent1);

3- Write a function:
void Master_MasterPageEvent1(object sender, EventArgs e)
{
//steps within handling the event
}
For more detail on raising and consuming events:
http://msdn2.microsoft.com/en-us/library/9aackb16.aspx
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Federico" wrote:
I have a problem, I have an event declared in a Master Page, and I want to
use in a Content Page holder of a Content Page. When I want to create the
method to handle the event, I can njot reference the Master Page event, in
its place IntelliSense shows me a Delegate Sub EventHandler. I am new with
events managements, so any help and guiadance will be appreciated.

Federico

Jan 17 '06 #4

P: n/a
Phillip thank you for your help. Now it works.

"Phillip Williams" wrote:
The link I posted previously has an example in VB that can guide you:
http://msdn2.microsoft.com/en-us/library/9aackb16.aspx

Briefly you needed to modify your code to look like this:

Public Delegate Sub MasterPageEventHandler1(sender As Object, e As
System.Web.UI.ImageClickEventArgs)

Partial Class MasterPage
Inherits System.Web.UI.MasterPage

Public Event1 As MasterPageEventHandler1
Protected Sub guardarImageButton_Click(ByVal sender As Object, ByVal e
As System.Web.UI.ImageClickEventArgs) Handles guardarImageButton.Click
RaiseEvent event1(Me, e)
End Sub

End Class

Then In the content page you need to get a reference to the master page like
this:
<%@ MasterType virtualPath="~/MasterPage.master"%>

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Federico" wrote:
I´m developing using VB 2005, I can not view the public event declarated in
the master page, from the content page, so i'm unable to wire up the event
with the handler.
Here is the source code from MasterPage

Partial Class MasterPage
Inherits System.Web.UI.MasterPage

Event event1(ByVal sender As Object, ByVal e As EventArgs)

Protected Sub guardarImageButton_Click(ByVal sender As Object, ByVal e
As System.Web.UI.ImageClickEventArgs) Handles guardarImageButton.Click
RaiseEvent event1(Me, e)
End Sub

End Class

Public Delegate Sub ManejadorEvento(ByVal sender As Object, ByVal e As
EventArgs)

....and here the code of content page

artial Class _Default
Inherits System.Web.UI.Page

Public Sub metodo()

End Sub

Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init
AddHandler Master.event1, AddressOf metodo ' this is the wrong line
End Sub
End Class

The error reported is:"'event1' is not an event of 'System.Web.UI.MasterPage'.

Please give me an example in VB 2005

Thanks

"Phillip Williams" wrote:
1- In the content page you need to get a reference to the master page like
this:
<%@ MasterType virtualPath="~/MasterPage.master"%>

http://msdn2.microsoft.com/en-us/library/c8y19k6h.aspx

2- Assuming that the master page raises and event (let's call it
MasterPageEvent1 that has a delegate named MyEventHandler) then you can wire
up an event handler in the content page like this:

Master.MasterPageEvent1+= new MyEventHandler(Master_MasterPageEvent1);

3- Write a function:
void Master_MasterPageEvent1(object sender, EventArgs e)
{
//steps within handling the event
}
For more detail on raising and consuming events:
http://msdn2.microsoft.com/en-us/library/9aackb16.aspx
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Federico" wrote:

> I have a problem, I have an event declared in a Master Page, and I want to
> use in a Content Page holder of a Content Page. When I want to create the
> method to handle the event, I can njot reference the Master Page event, in
> its place IntelliSense shows me a Delegate Sub EventHandler. I am new with
> events managements, so any help and guiadance will be appreciated.
>
> Federico

Jan 17 '06 #5

P: n/a
Great help Phillip!!

I was within the same error!!

See ya!@!

"Phillip Williams" <Ph**************@webswapp.com> escreveu na mensagem
news:1D**********************************@microsof t.com...
The link I posted previously has an example in VB that can guide you:
http://msdn2.microsoft.com/en-us/library/9aackb16.aspx

Briefly you needed to modify your code to look like this:

Public Delegate Sub MasterPageEventHandler1(sender As Object, e As
System.Web.UI.ImageClickEventArgs)

Partial Class MasterPage
Inherits System.Web.UI.MasterPage

Public Event1 As MasterPageEventHandler1
Protected Sub guardarImageButton_Click(ByVal sender As Object, ByVal e
As System.Web.UI.ImageClickEventArgs) Handles guardarImageButton.Click
RaiseEvent event1(Me, e)
End Sub

End Class

Then In the content page you need to get a reference to the master page
like
this:
<%@ MasterType virtualPath="~/MasterPage.master"%>

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Federico" wrote:
Im developing using VB 2005, I can not view the public event declarated
in
the master page, from the content page, so i'm unable to wire up the
event
with the handler.
Here is the source code from MasterPage

Partial Class MasterPage
Inherits System.Web.UI.MasterPage

Event event1(ByVal sender As Object, ByVal e As EventArgs)

Protected Sub guardarImageButton_Click(ByVal sender As Object, ByVal
e
As System.Web.UI.ImageClickEventArgs) Handles guardarImageButton.Click
RaiseEvent event1(Me, e)
End Sub

End Class

Public Delegate Sub ManejadorEvento(ByVal sender As Object, ByVal e As
EventArgs)

....and here the code of content page

artial Class _Default
Inherits System.Web.UI.Page

Public Sub metodo()

End Sub

Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init
AddHandler Master.event1, AddressOf metodo ' this is the wrong
line
End Sub
End Class

The error reported is:"'event1' is not an event of
'System.Web.UI.MasterPage'.

Please give me an example in VB 2005

Thanks

"Phillip Williams" wrote:
> 1- In the content page you need to get a reference to the master page
> like
> this:
> <%@ MasterType virtualPath="~/MasterPage.master"%>
>
> http://msdn2.microsoft.com/en-us/library/c8y19k6h.aspx
>
> 2- Assuming that the master page raises and event (let's call it
> MasterPageEvent1 that has a delegate named MyEventHandler) then you can
> wire
> up an event handler in the content page like this:
>
> Master.MasterPageEvent1+= new MyEventHandler(Master_MasterPageEvent1);
>
> 3- Write a function:
> void Master_MasterPageEvent1(object sender, EventArgs e)
> {
> //steps within handling the event
> }
> For more detail on raising and consuming events:
> http://msdn2.microsoft.com/en-us/library/9aackb16.aspx
>
>
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "Federico" wrote:
>
> > I have a problem, I have an event declared in a Master Page, and I
> > want to
> > use in a Content Page holder of a Content Page. When I want to create
> > the
> > method to handle the event, I can njot reference the Master Page
> > event, in
> > its place IntelliSense shows me a Delegate Sub EventHandler. I am new
> > with
> > events managements, so any help and guiadance will be appreciated.
> >
> > Federico

Feb 1 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.