473,322 Members | 1,287 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,322 software developers and data experts.

WithEvents Question

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

Nov 19 '05 #1
4 1584
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

Nov 19 '05 #2
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

"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:ba****@NOSPAMdevelop.com:
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


Nov 19 '05 #3
It means you need a:

Dim WithEvents cmenu01 as WhateverTypeItIs

Are you in VS.NET 2003 or VS.NET 2005?

-Brock
DevelopMentor
http://staff.develop.com/ballen
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
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:ba****@NOSPAMdevelop.com:
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


Nov 19 '05 #4
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

"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:ba****@NOSPAMdevelop.com:
It means you need a:

Dim WithEvents cmenu01 as WhateverTypeItIs

Are you in VS.NET 2003 or VS.NET 2005?

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

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
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:ba****@NOSPAMdevelop.com:

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


Nov 19 '05 #5

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

Similar topics

7
by: Jonas | last post by:
This works fine in Win XP but does not work at all in Win 98. Private WithEvents objIExplorer As InternetExplorer I have to do it like this to get it to work in Win 98 Dim objIExplorer As...
2
by: Jakob Bengtsson | last post by:
Hi, I have a form (which cannot be serialized). In the form's code I declare an object like this (never mind the object nor class name, it's for illustration only): Private WithEvents...
5
by: Bradley Grant | last post by:
I am trying to write a program to access a device through USB port, there is some Visual Basic program examples that work with the device, but I am trying to write a program using C#, no luck yet,...
2
by: Peter | last post by:
Hello, Thanks for reviewing my question. I am following KB article about creating a custom control and its source code is in VB. I got to a part where I have the following: Private...
11
by: Brett | last post by:
What is the C# equivalent for this VB.NET code: Private WithEvents IE_Inst As New SHDocVw.InternetExplorer I get as far as: private SHDocVw.InternetExplorer IE_Inst = new...
2
by: Benign Vanilla | last post by:
I am a ASP.NET newbie so please bear with me. I had a series of webforms working on my web site, and then I made some tragic error that is causing all kinds of problems. The main symptom is that...
0
by: Steve | last post by:
Hello, I have been experimenting/learning to use aspx with and without VS2003. In VS 2003 I created a simple webform/application which contains a listbox and a label. I populate the listbox...
6
by: | last post by:
Is there any additional overhead for declaring a variable using the WithEvents keyword even if none of the events are being handled?
8
by: Bob Day | last post by:
Using VS 2003, VB.NET, MSDE If an event is raised in a class that was NOT instantiated with the WithEvents key word, is that event effectively ignored? Or, another way to phrase the question,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.