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

Calling web form method from user control

P: n/a
Hi All,

I am trying to call a method in a web form, from an event fired in a user
control. My user control displays a map, which has a link button to
enlarge/shrink the map. When the user enlarges the map, I want to hide my
navigation table etc, maximising the viewing area. I've been working on this
for 5 hours now, so far I have as detailed below - Which rund with out
error, but the final function never gets called. Any help/suggestions would
be appreciated.
Heres how far I have got:
==================

1) My user control is called map_display.ascx. This contains a link button,
onclick does the following, which is in map_display.ascx.vb:

Private Sub lbEnlarge_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lbEnlarge.Click
Dim evt As New EventArgs
Call MyEnlarge(e)
If Me.lbEnlarge.Text = "Shrink" Then
ChangeMapSize(pInitialMapSize)
Me.lbEnlarge.Text = "Enlarge"
Else
ChangeMapSize("700x350")
Me.lbEnlarge.Text = "Shrink"
End If
End Sub

2) 'MyEnlarge' is also within map_display.ascx.vb:
(Note public delegate and event lines, which I also added)

Public Delegate Sub EnlargeButtonHandler(ByVal sender As Object, ByVal e As
EventArgs)
Public Event EnlargeButton As EnlargeButtonHandler
Protected Sub MyEnlarge(ByVal e As EventArgs)
RaiseEvent EnlargeButton(Me, e)
End Sub

3) In my containing aspx page (Called map_and_property_info.aspx), the user
control is included like this:

<uc1:map_display id="Map_display1" runat="server"
onMyEnlarge="ToggleTblNavandInfo"></uc1:map_display>

The plan was to 'catch' the original event of the user clicking the link
button in the user control, then fire a function in the ASPX code behind -
Probably not relevent, but heres the function I wanted to eventually call.

Public Sub ToggleTblNavandInfo()
If Me.TblNavandInfo.Visible = False Then
Me.TblNavandInfo.Visible = True
Else
Me.TblNavandInfo.Visible = False
End If
End Sub

Nov 19 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Shouldn't that be
onEnlargeButton
instead of
onMyEnlarge in the <uc1: control?

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Simon Harris" <to***********@makes-you-fat.com> wrote in message
news:er*************@TK2MSFTNGP15.phx.gbl...
Hi All,

I am trying to call a method in a web form, from an event fired in a user
control. My user control displays a map, which has a link button to
enlarge/shrink the map. When the user enlarges the map, I want to hide my
navigation table etc, maximising the viewing area. I've been working on this for 5 hours now, so far I have as detailed below - Which rund with out
error, but the final function never gets called. Any help/suggestions would be appreciated.
Heres how far I have got:
==================

1) My user control is called map_display.ascx. This contains a link button, onclick does the following, which is in map_display.ascx.vb:

Private Sub lbEnlarge_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lbEnlarge.Click
Dim evt As New EventArgs
Call MyEnlarge(e)
If Me.lbEnlarge.Text = "Shrink" Then
ChangeMapSize(pInitialMapSize)
Me.lbEnlarge.Text = "Enlarge"
Else
ChangeMapSize("700x350")
Me.lbEnlarge.Text = "Shrink"
End If
End Sub

2) 'MyEnlarge' is also within map_display.ascx.vb:
(Note public delegate and event lines, which I also added)

Public Delegate Sub EnlargeButtonHandler(ByVal sender As Object, ByVal e As EventArgs)
Public Event EnlargeButton As EnlargeButtonHandler
Protected Sub MyEnlarge(ByVal e As EventArgs)
RaiseEvent EnlargeButton(Me, e)
End Sub

3) In my containing aspx page (Called map_and_property_info.aspx), the user control is included like this:

<uc1:map_display id="Map_display1" runat="server"
onMyEnlarge="ToggleTblNavandInfo"></uc1:map_display>

The plan was to 'catch' the original event of the user clicking the link
button in the user control, then fire a function in the ASPX code behind -
Probably not relevent, but heres the function I wanted to eventually call.

Public Sub ToggleTblNavandInfo()
If Me.TblNavandInfo.Visible = False Then
Me.TblNavandInfo.Visible = True
Else
Me.TblNavandInfo.Visible = False
End If
End Sub

Nov 19 '05 #2

P: n/a
Hi Karl,

I changed it to onEnlargeButton and I now get this error:

===============================
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30408: Method 'Public Sub ToggleTblNavandInfo()'
does not have the same signature as delegate 'Delegate Sub
EnlargeButtonHandler(sender As Object, e As System.EventArgs)'.

Source Error:
Line 87: </table>
Line 88: </td>
Line 89: <td><uc1:map_display id="Map_display1" runat="server"
onEnlargeButton="ToggleTblNavandInfo"></uc1:map_display></td>
Line 90: </tr>
Line 91: </table>
Source File: D:\introot\netapps\gis\map_and_property_info.aspx Line: 89

===============================
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:um*************@TK2MSFTNGP15.phx.gbl...
Shouldn't that be
onEnlargeButton
instead of
onMyEnlarge in the <uc1: control?

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Simon Harris" <to***********@makes-you-fat.com> wrote in message
news:er*************@TK2MSFTNGP15.phx.gbl...
Hi All,

I am trying to call a method in a web form, from an event fired in a user
control. My user control displays a map, which has a link button to
enlarge/shrink the map. When the user enlarges the map, I want to hide my
navigation table etc, maximising the viewing area. I've been working on

this
for 5 hours now, so far I have as detailed below - Which rund with out
error, but the final function never gets called. Any help/suggestions

would
be appreciated.
Heres how far I have got:
==================

1) My user control is called map_display.ascx. This contains a link

button,
onclick does the following, which is in map_display.ascx.vb:

Private Sub lbEnlarge_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lbEnlarge.Click
Dim evt As New EventArgs
Call MyEnlarge(e)
If Me.lbEnlarge.Text = "Shrink" Then
ChangeMapSize(pInitialMapSize)
Me.lbEnlarge.Text = "Enlarge"
Else
ChangeMapSize("700x350")
Me.lbEnlarge.Text = "Shrink"
End If
End Sub

2) 'MyEnlarge' is also within map_display.ascx.vb:
(Note public delegate and event lines, which I also added)

Public Delegate Sub EnlargeButtonHandler(ByVal sender As Object, ByVal e

As
EventArgs)
Public Event EnlargeButton As EnlargeButtonHandler
Protected Sub MyEnlarge(ByVal e As EventArgs)
RaiseEvent EnlargeButton(Me, e)
End Sub

3) In my containing aspx page (Called map_and_property_info.aspx), the

user
control is included like this:

<uc1:map_display id="Map_display1" runat="server"
onMyEnlarge="ToggleTblNavandInfo"></uc1:map_display>

The plan was to 'catch' the original event of the user clicking the link
button in the user control, then fire a function in the ASPX code
behind -
Probably not relevent, but heres the function I wanted to eventually
call.

Public Sub ToggleTblNavandInfo()
If Me.TblNavandInfo.Visible = False Then
Me.TblNavandInfo.Visible = True
Else
Me.TblNavandInfo.Visible = False
End If
End Sub


Nov 19 '05 #3

P: n/a
Simon,
I had noticed this but forgot to mention it, the ToggleTblNavandInfo
function has to have the same signature (return type and parameters) as your
delegate, in other words it needs to be:

Public Sub ToggleTblNavandInfo (sender As Object, e As System.EventArgs)
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Simon Harris" <to***********@makes-you-fat.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi Karl,

I changed it to onEnlargeButton and I now get this error:

===============================
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30408: Method 'Public Sub ToggleTblNavandInfo()'
does not have the same signature as delegate 'Delegate Sub
EnlargeButtonHandler(sender As Object, e As System.EventArgs)'.

Source Error:
Line 87: </table>
Line 88: </td>
Line 89: <td><uc1:map_display id="Map_display1" runat="server"
onEnlargeButton="ToggleTblNavandInfo"></uc1:map_display></td>
Line 90: </tr>
Line 91: </table>
Source File: D:\introot\netapps\gis\map_and_property_info.aspx Line: 89

===============================
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:um*************@TK2MSFTNGP15.phx.gbl...
Shouldn't that be
onEnlargeButton
instead of
onMyEnlarge in the <uc1: control?

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Simon Harris" <to***********@makes-you-fat.com> wrote in message
news:er*************@TK2MSFTNGP15.phx.gbl...
Hi All,

I am trying to call a method in a web form, from an event fired in a user control. My user control displays a map, which has a link button to
enlarge/shrink the map. When the user enlarges the map, I want to hide my navigation table etc, maximising the viewing area. I've been working on

this
for 5 hours now, so far I have as detailed below - Which rund with out
error, but the final function never gets called. Any help/suggestions

would
be appreciated.
Heres how far I have got:
==================

1) My user control is called map_display.ascx. This contains a link

button,
onclick does the following, which is in map_display.ascx.vb:

Private Sub lbEnlarge_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lbEnlarge.Click
Dim evt As New EventArgs
Call MyEnlarge(e)
If Me.lbEnlarge.Text = "Shrink" Then
ChangeMapSize(pInitialMapSize)
Me.lbEnlarge.Text = "Enlarge"
Else
ChangeMapSize("700x350")
Me.lbEnlarge.Text = "Shrink"
End If
End Sub

2) 'MyEnlarge' is also within map_display.ascx.vb:
(Note public delegate and event lines, which I also added)

Public Delegate Sub EnlargeButtonHandler(ByVal sender As Object, ByVal e
As
EventArgs)
Public Event EnlargeButton As EnlargeButtonHandler
Protected Sub MyEnlarge(ByVal e As EventArgs)
RaiseEvent EnlargeButton(Me, e)
End Sub

3) In my containing aspx page (Called map_and_property_info.aspx), the

user
control is included like this:

<uc1:map_display id="Map_display1" runat="server"
onMyEnlarge="ToggleTblNavandInfo"></uc1:map_display>

The plan was to 'catch' the original event of the user clicking the

link button in the user control, then fire a function in the ASPX code
behind -
Probably not relevent, but heres the function I wanted to eventually
call.

Public Sub ToggleTblNavandInfo()
If Me.TblNavandInfo.Visible = False Then
Me.TblNavandInfo.Visible = True
Else
Me.TblNavandInfo.Visible = False
End If
End Sub



Nov 19 '05 #4

P: n/a
Hi Karl,

Just changed my function as you suggested...IT WORKS!!! Woo Hoo!! (Calm down
man, calm down!) :)

I reasonably new to .Net...although it is working now, I dont know why -
Perhaps you could explain a little?

Thank you for your help.

Simon.

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
Simon,
I had noticed this but forgot to mention it, the ToggleTblNavandInfo
function has to have the same signature (return type and parameters) as
your
delegate, in other words it needs to be:

Public Sub ToggleTblNavandInfo (sender As Object, e As System.EventArgs)
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Simon Harris" <to***********@makes-you-fat.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi Karl,

I changed it to onEnlargeButton and I now get this error:

===============================
Compilation Error
Description: An error occurred during the compilation of a resource

required
to service this request. Please review the following specific error

details
and modify your source code appropriately.

Compiler Error Message: BC30408: Method 'Public Sub
ToggleTblNavandInfo()'
does not have the same signature as delegate 'Delegate Sub
EnlargeButtonHandler(sender As Object, e As System.EventArgs)'.

Source Error:
Line 87: </table>
Line 88: </td>
Line 89: <td><uc1:map_display id="Map_display1" runat="server"
onEnlargeButton="ToggleTblNavandInfo"></uc1:map_display></td>
Line 90: </tr>
Line 91: </table>
Source File: D:\introot\netapps\gis\map_and_property_info.aspx Line:
89

===============================
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:um*************@TK2MSFTNGP15.phx.gbl...
> Shouldn't that be
> onEnlargeButton
> instead of
> onMyEnlarge in the <uc1: control?
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "Simon Harris" <to***********@makes-you-fat.com> wrote in message
> news:er*************@TK2MSFTNGP15.phx.gbl...
>> Hi All,
>>
>> I am trying to call a method in a web form, from an event fired in a user >> control. My user control displays a map, which has a link button to
>> enlarge/shrink the map. When the user enlarges the map, I want to hide my >> navigation table etc, maximising the viewing area. I've been working
>> on
> this
>> for 5 hours now, so far I have as detailed below - Which rund with out
>> error, but the final function never gets called. Any help/suggestions
> would
>> be appreciated.
>>
>>
>> Heres how far I have got:
>> ==================
>>
>> 1) My user control is called map_display.ascx. This contains a link
> button,
>> onclick does the following, which is in map_display.ascx.vb:
>>
>> Private Sub lbEnlarge_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles lbEnlarge.Click
>> Dim evt As New EventArgs
>> Call MyEnlarge(e)
>> If Me.lbEnlarge.Text = "Shrink" Then
>> ChangeMapSize(pInitialMapSize)
>> Me.lbEnlarge.Text = "Enlarge"
>> Else
>> ChangeMapSize("700x350")
>> Me.lbEnlarge.Text = "Shrink"
>> End If
>> End Sub
>>
>>
>>
>> 2) 'MyEnlarge' is also within map_display.ascx.vb:
>> (Note public delegate and event lines, which I also added)
>>
>> Public Delegate Sub EnlargeButtonHandler(ByVal sender As Object, ByVal e > As
>> EventArgs)
>> Public Event EnlargeButton As EnlargeButtonHandler
>> Protected Sub MyEnlarge(ByVal e As EventArgs)
>> RaiseEvent EnlargeButton(Me, e)
>> End Sub
>>
>>
>>
>> 3) In my containing aspx page (Called map_and_property_info.aspx), the
> user
>> control is included like this:
>>
>> <uc1:map_display id="Map_display1" runat="server"
>> onMyEnlarge="ToggleTblNavandInfo"></uc1:map_display>
>>
>> The plan was to 'catch' the original event of the user clicking the link >> button in the user control, then fire a function in the ASPX code
>> behind -
>> Probably not relevent, but heres the function I wanted to eventually
>> call.
>>
>> Public Sub ToggleTblNavandInfo()
>> If Me.TblNavandInfo.Visible = False Then
>> Me.TblNavandInfo.Visible = True
>> Else
>> Me.TblNavandInfo.Visible = False
>> End If
>> End Sub
>>
>>
>>
>
>



Nov 19 '05 #5

P: n/a
Simon:
Not sure what you don't understand. The delegate and function signature?
Deep down all of this is just function pointers...a function pointer allows
you to dynamically run a function. However, it only works when you know the
exact signature of the function (return type, parameter type). Delegates
are like function pointers...you dynamically invoke the function that's
hooked to the event, but it has to have the exact same signature as your
delegate

An event has a delegate type
only function which have the same signature as defined by the delegate type
can be hooked into the event...

Hope that helped :)

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Simon Harris" <to***********@makes-you-fat.com> wrote in message
news:%2*****************@TK2MSFTNGP09.phx.gbl...
Hi Karl,

Just changed my function as you suggested...IT WORKS!!! Woo Hoo!! (Calm down man, calm down!) :)

I reasonably new to .Net...although it is working now, I dont know why -
Perhaps you could explain a little?

Thank you for your help.

Simon.

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
Simon,
I had noticed this but forgot to mention it, the ToggleTblNavandInfo
function has to have the same signature (return type and parameters) as
your
delegate, in other words it needs to be:

Public Sub ToggleTblNavandInfo (sender As Object, e As System.EventArgs)
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Simon Harris" <to***********@makes-you-fat.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi Karl,

I changed it to onEnlargeButton and I now get this error:

===============================
Compilation Error
Description: An error occurred during the compilation of a resource

required
to service this request. Please review the following specific error

details
and modify your source code appropriately.

Compiler Error Message: BC30408: Method 'Public Sub
ToggleTblNavandInfo()'
does not have the same signature as delegate 'Delegate Sub
EnlargeButtonHandler(sender As Object, e As System.EventArgs)'.

Source Error:
Line 87: </table>
Line 88: </td>
Line 89: <td><uc1:map_display id="Map_display1" runat="server"
onEnlargeButton="ToggleTblNavandInfo"></uc1:map_display></td>
Line 90: </tr>
Line 91: </table>
Source File: D:\introot\netapps\gis\map_and_property_info.aspx Line:
89

===============================
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:um*************@TK2MSFTNGP15.phx.gbl...
> Shouldn't that be
> onEnlargeButton
> instead of
> onMyEnlarge in the <uc1: control?
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "Simon Harris" <to***********@makes-you-fat.com> wrote in message
> news:er*************@TK2MSFTNGP15.phx.gbl...
>> Hi All,
>>
>> I am trying to call a method in a web form, from an event fired in a

user
>> control. My user control displays a map, which has a link button to
>> enlarge/shrink the map. When the user enlarges the map, I want to hide
my
>> navigation table etc, maximising the viewing area. I've been working
>> on
> this
>> for 5 hours now, so far I have as detailed below - Which rund with
out >> error, but the final function never gets called. Any help/suggestions > would
>> be appreciated.
>>
>>
>> Heres how far I have got:
>> ==================
>>
>> 1) My user control is called map_display.ascx. This contains a link
> button,
>> onclick does the following, which is in map_display.ascx.vb:
>>
>> Private Sub lbEnlarge_Click(ByVal sender As System.Object, ByVal e As >> System.EventArgs) Handles lbEnlarge.Click
>> Dim evt As New EventArgs
>> Call MyEnlarge(e)
>> If Me.lbEnlarge.Text = "Shrink" Then
>> ChangeMapSize(pInitialMapSize)
>> Me.lbEnlarge.Text = "Enlarge"
>> Else
>> ChangeMapSize("700x350")
>> Me.lbEnlarge.Text = "Shrink"
>> End If
>> End Sub
>>
>>
>>
>> 2) 'MyEnlarge' is also within map_display.ascx.vb:
>> (Note public delegate and event lines, which I also added)
>>
>> Public Delegate Sub EnlargeButtonHandler(ByVal sender As Object, ByVal e
> As
>> EventArgs)
>> Public Event EnlargeButton As EnlargeButtonHandler
>> Protected Sub MyEnlarge(ByVal e As EventArgs)
>> RaiseEvent EnlargeButton(Me, e)
>> End Sub
>>
>>
>>
>> 3) In my containing aspx page (Called map_and_property_info.aspx),

the > user
>> control is included like this:
>>
>> <uc1:map_display id="Map_display1" runat="server"
>> onMyEnlarge="ToggleTblNavandInfo"></uc1:map_display>
>>
>> The plan was to 'catch' the original event of the user clicking the

link
>> button in the user control, then fire a function in the ASPX code
>> behind -
>> Probably not relevent, but heres the function I wanted to eventually
>> call.
>>
>> Public Sub ToggleTblNavandInfo()
>> If Me.TblNavandInfo.Visible = False Then
>> Me.TblNavandInfo.Visible = True
>> Else
>> Me.TblNavandInfo.Visible = False
>> End If
>> End Sub
>>
>>
>>
>
>



Nov 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.