Can't Access Button Click Event Handler(VB.net)

  • Thread starter Thread starter George
  • Start date Start date
G

George

I'm having a weird problem.

When I double-click a Web server control that I have on my design-time Web
form, such as a button, it puts the event handler in the Code Behind as a
Private Sub routine. However, when I try to compile, I get an error saying
that I can't access that event handler because it is Private.

When I change the event handler from Private Sub to Public Sub, it works
fine, but I know that is not the way it is supposed to be because I had it
working the other way before. Plus, there is no reason that the VS
design-time envrironment would put a Private Sub routine in the Code Behind
if it wasn't supposed to be Private, right?

So why do I get a compile error saying I can't access that click-event
handler because "in this context, it is Private?"

Thanks,
George
 
If, for some reason, you have coded the onclick="blah" definition in the
HTML section and the event is not at least "Shared" in scope, you will get
this error. Double check the button in the HTML section and make sure you
don't have any hard-wired "on<blah>" events in the HTML section.
 
Morgan,

That was the problem!

I had hard-coded the onclick="Button_Click" in the HTML code. I thought I
was supposed to do that to get the click-event to trigger. Man, the learning
curve for this will melt your brain, I'm telling you. ;-)

I really appreciate your help and time.
Thanks.
George
 
Back
Top