WithEvents Question

S

Shapper

Hello,

I have an aspx.vb page with this code:

Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents Menu1 As MenuControl.Web.UI.Menu
...

If I have my code in the aspx page itself what the code line "Protected
WithEvents Menu1 As MenuControl.Web.UI.Menu" should look like in my aspx
page. I just don't know how to declare an WithEvents Variable on a
aspx.page.

Thanks,
Miguel
 
B

Brock Allen

You use WithEvents if you want to handle events on that object using the
syntax:

Sub Button1_Clck() Handles Button1.Click
If I have my code in the aspx page itself what the code line
"Protected WithEvents Menu1 As MenuControl.Web.UI.Menu" should look
like in my aspx page. I just don't know how to declare an WithEvents
Variable on a aspx.page.

I'm not sure what your question is, since the code block you show is declaring
a variable that way. You only use it when you want to automatically handle
the events as I mention above. Otherwise you don't need it.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
S

Shapper

Hello,

I have this in my aspx page:
Sub cmenu01_MenuItemSelected(ByVal sender As System.Object, ByVal e As
MenuControl.Web.UI.MenuItemEventArgs) Handles cmenu01.ItemSelected
changeCulture(e.Item.Text)
End Sub

And I get this error:
Handles clause requires a WithEvents variable.

That is my problem.

What am I doing wrong?

Thanks,
Miguel
 
S

Shapper

Hi,

I had added that before but I got the following message:
cmenu01' is already declared as 'Protected Dim cmenu01 As MyType' in
this class.

Do you know why?

I am working with Web Matrix because I just moved recently to ASP.NET.

I did use VS2003 for a while but it was a little bit confusing.
Since VS2005 and ASP.NET 2.0 are coming by the end of this year I
decided to keep working on Web Matrix.

Maybe I should go back to VS2003 again...

Cheers,
Miguel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top