2 Replies - 468 Views - Last Post: 09 January 2019 - 03:46 AM

#1 SteveHi   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 62
  • Joined: 07-June 15

WithEvents variable error

Posted 08 January 2019 - 08:50 PM

Hello

I am getting a red underline (under the second 'LogonBtn') with the following error:

Protected Sub LogonBtn_Click(sender As Object, e As EventArgs) Handles LogonBtn.Click


Handles clause requires a WithEvents variable defined in the containing type or one of its base types

'LogonBtn' refers to this line of code I have in the corresponding aspx file:

<asp:Button ID="LogonBtn" runat="server" Text="Log in" CssClass="submit" onclick="LogonBtn_Click" />


If the line of code I have is, indeed, incorrect, what should it be, please?

Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: WithEvents variable error

#2 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6818
  • View blog
  • Posts: 28,228
  • Joined: 12-December 12

Re: WithEvents variable error

Posted 09 January 2019 - 02:13 AM

Is this an existing application that you are trying to update?

This link is from searching the error message. It appears that there might be some discrepancy between the code and designer.

Also, although I don't use (old) ASP.NET, do you need the onclick attribute? It looks like duplication to me.
Was This Post Helpful? 0
  • +
  • -

#3 SteveHi   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 62
  • Joined: 07-June 15

Re: WithEvents variable error

Posted 09 January 2019 - 03:46 AM

Thanks, Andrewsw

It has accepted this:

Protected Sub LogonBtn_Click(sender As Object, e As EventArgs)


Cheers!

Steve

This post has been edited by SteveHi: 09 January 2019 - 03:47 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1