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

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
 
M

Morgan

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.
 
G

George

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
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top