469,641 Members | 1,195 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,641 developers. It's quick & easy.

Error BC30506 trying to add even for a button

I have a page in ASP.NET 2.0. I add a button in design view and the
page runs fine. I then double-click the button to create the click
method in the code. Then when I run the page I get the error "error
BC30506: Handles clause requires a WithEvents variable defined in the
containing type or one of its base types."

I have tried deleting the button and re-adding it numerous times with
different names and every time I get the same error. I have another
button on the page that works fine. All the info on this error talks
about if the control is dynamically created, there is nothing that
talks about if it is created as part of the page design. Does anyone
know how to fix it?

Thanks.
Nov 29 '07 #1
4 5327
On Nov 29, 10:23 pm, Dennis <dbronst...@gmail.comwrote:
I have a page in ASP.NET 2.0. I add a button in design view and the
page runs fine. I then double-click the button to create the click
method in the code. Then when I run the page I get the error "error
BC30506: Handles clause requires a WithEvents variable defined in the
containing type or one of its base types."

I have tried deleting the button and re-adding it numerous times with
different names and every time I get the same error. I have another
button on the page that works fine. All the info on this error talks
about if the control is dynamically created, there is nothing that
talks about if it is created as part of the page design. Does anyone
know how to fix it?

Thanks.
http://msdn2.microsoft.com/en-us/lib...t6(vs.80).aspx
Nov 30 '07 #2
So where do I add the withevents variable? Here is my handles clause:

Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSave.Click

And why do I have to do this now? I've never had to do it in any other
page I've created and I didn't have to do it with the other button on
the page, that one works just fine.
On Nov 30, 7:26 am, Alexey Smirnov <alexey.smir...@gmail.comwrote:
On Nov 29, 10:23 pm, Dennis <dbronst...@gmail.comwrote:
I have a page in ASP.NET 2.0. I add a button in design view and the
page runs fine. I then double-click the button to create the click
method in the code. Then when I run the page I get the error "error
BC30506: Handles clause requires a WithEvents variable defined in the
containing type or one of its base types."
I have tried deleting the button and re-adding it numerous times with
different names and every time I get the same error. I have another
button on the page that works fine. All the info on this error talks
about if the control is dynamically created, there is nothing that
talks about if it is created as part of the page design. Does anyone
know how to fix it?
Thanks.

http://msdn2.microsoft.com/en-us/lib...t6(vs.80).aspx
Nov 30 '07 #3
On Nov 30, 4:22 pm, Dennis <dbronst...@gmail.comwrote:
So where do I add the withevents variable? Here is my handles clause:

Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSave.Click

And why do I have to do this now? I've never had to do it in any other
page I've created and I didn't have to do it with the other button on
the page, that one works just fine.

On Nov 30, 7:26 am, Alexey Smirnov <alexey.smir...@gmail.comwrote:
On Nov 29, 10:23 pm, Dennis <dbronst...@gmail.comwrote:
I have a page in ASP.NET 2.0. I add a button in design view and the
page runs fine. I then double-click the button to create the click
method in the code. Then when I run the page I get the error "error
BC30506: Handles clause requires a WithEvents variable defined in the
containing type or one of its base types."
I have tried deleting the button and re-adding it numerous times with
different names and every time I get the same error. I have another
button on the page that works fine. All the info on this error talks
about if the control is dynamically created, there is nothing that
talks about if it is created as part of the page design. Does anyone
know how to fix it?
Thanks.
http://msdn2.microsoft.com/en-us/lib...6(vs.80).aspx- Hide quoted text -

- Show quoted text -
The WithEvents statement and the Handles clause provide a declarative
way of specifying event handlers. An event raised by an object
declared with the WithEvents keyword can be handled by any procedure
with a Handles statement for that event

Protected WithEvents btnSave As System.Web.UI.WebControls.Button

.....

Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSave.Click
Dec 4 '07 #4
But I'm not dynamically creating the button. I'm just dropping it
onto the page in design view - it has an asp:Button tag in source
view. There is no declaration statement.

On Dec 4, 2:21 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:
>
The WithEvents statement and the Handles clause provide a declarative
way of specifying event handlers. An event raised by an object
declared with the WithEvents keyword can be handled by any procedure
with a Handles statement for that event

Protected WithEvents btnSave As System.Web.UI.WebControls.Button

....

Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSave.Click- Hide quoted text -

- Show quoted text -
Dec 7 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Peter Frost | last post: by
7 posts views Thread by Kris Desmadryl | last post: by
16 posts views Thread by Paul S. Natanson | last post: by
reply views Thread by mchuc7719 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.