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

Discussion in 'ASP .Net' started by George, Jan 28, 2004.

  1. George

    George Guest

    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
     
    George, Jan 28, 2004
    #1
    1. Advertising

  2. George

    Morgan Guest

    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.


    "George" <------@----.---> wrote in message
    news:SZCRb.26269$...
    > 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
    >
    >
    >
     
    Morgan, Jan 28, 2004
    #2
    1. Advertising

  3. George

    George Guest

    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


    "Morgan" <> wrote in message
    news:...
    > 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.
    >
    >
    > "George" <------@----.---> wrote in message
    > news:SZCRb.26269$...
    > > 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
    > >
    > >
    > >

    >
    >
     
    George, Jan 28, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Purvi T
    Replies:
    0
    Views:
    843
    Purvi T
    Oct 19, 2004
  2. sonic
    Replies:
    1
    Views:
    538
    John Saunders
    Jan 7, 2005
  3. Amy
    Replies:
    0
    Views:
    988
  4. Replies:
    1
    Views:
    703
    Damien
    Feb 22, 2007
  5. Max2006
    Replies:
    2
    Views:
    1,575
    Walter Wang [MSFT]
    Sep 19, 2007
Loading...

Share This Page