473,385 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Handling events generated by a Master Page in a content placeholde

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
5 2520
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
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
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
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
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:
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

Feb 1 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Eric Newton | last post by:
VB's more declarative nature of handling events is golden. I'm hoping C# will acquire this type of deal, in addition to the anonymous delegates. could do same as vb (actually would be easier to...
2
by: Jorge Ayala | last post by:
Well I'm trying to catch and act upon a button event that is placed within the item template of a repeater control. Yet the code I'm using isn't working. What I've seen out there to explain how...
5
by: Michael Herman \(Parallelspace\) | last post by:
1. What are some compelling solutions for using Master/Content pages with Web Pages? 2. If a content area has a web part zone with web parts, what is the user experience like when "editting" the...
12
by: scsharma | last post by:
Hi, I am working on creating a webapplication and my design calls for creating main webform which will have menu bar on left hand side and a IFrame which will contain all the forms that are shown...
1
by: dezza | last post by:
Hi, I am developing a web application that is a series of pages, rather like a wizard. Because all of the pages basically have the same navigation, and require the navigation buttons in the...
1
by: Apu Nahasapeemapetilon | last post by:
Hello and thank you in advance for your help. Can anyone think of a reason why this code would work properly on one PC, but not another? I've got a System.Windows.Forms.UserControl that...
1
by: LilC | last post by:
I'm creating an application that has a standard layout for all pages. The information that is displayed in the layout will be dynamic based on the user that is logged in. Thus when a page is...
6
by: Steve Hershoff | last post by:
Hi everyone, I've got a strange one here. There are two datagrids on my page, one nested within the other. I'll refer to them as the topmost and secondary datagrids. In the topmost...
0
by: richard.haber | last post by:
I have a situation where there are two controls on the master page: a tree with a menu structure (whose content and structure is customizable by each user) and a menu control which displays the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.