Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BC30269: 'Protected Sub btnLogin_Click error 1

Status
Not open for further replies.

Everton1Blue

Technical User
Jun 6, 2014
41
GB
Hello

I am getting the following error:

BC30269: 'Protected Sub btnLogin_Click(sender As Object, e As EventArgs) 'has multiple definitions with identical signatures'.

I take it that the error refers to the fact that I use Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) again in the same aspx file?

Is it possible to remove one Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) 'header' and combine the code under a single 'header' or how else to deal with the error?

Many thanks
 
Simple answer: you are correct, but only you can determine if you can "combine" them.

More complicated: Basically what you've ended up with is two methods with the same name in the same class. Remember classes can be split between files (partial classes), or even inherited. Whenever you have two methods with the same name and the same parameters in the same class you will get this error.

You haven't really given us the code for the headers methods, so we can't really tell you if you can combine them. You'll have to work out the logic of each method, and the order of operations that need to happen to be able to determine if/how you can combine them. ONE of them has to go in order to get rid of the error and put your application into a working state.

Based on the name of your methods "btnLogin_Click" it looks like it is supposed to be an event handler for a button. While you CAN have multiple handlers for an event (with different method names: "btnLogin_Click" and "btnLogin_Click_1"), it is not advisable to split up your code that way - it is more confusing for the program flow.
 
Thanks for getting back to me, Borvik.

One sub relates to a user logging on via a login form so the code will scrutinise the database to check that he exists as a registrant. This code (I am sure there are errors with it as I have not done a login form before) is:

Code:
Protected Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click

        Dim strEmail As Boolean

        Dim result As String = VerifyAccount(strEmail, password.Text)

        If result = True Then

            Session("ValidUser") = True

            Session("strEmail") = GetUser(strEmail)

            Response.Redirect("userpage.aspx")

        Else

            Session("ValidUser") = False


        End If

    End Sub

while the second btnLogin_Click , sets up cookies if that user has checked/ticked the 'Remember Me' checkbox.

To me, there is a logic in that order of things but, as I say, it's the first time I have done this.

Thanks again.
 
Your code does not look like VB.NET (to me)
Are you sure you are in the right Forum here at TT...?
Shouldn't you be in ASP.NET, maybe...?

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
I can see the confusion - ASP.NET can be either VB or C#, and Everton1Blue is using VB codebehind for it.

However, Andrzejek is also correct - as ASP.NET has its own forum: forum855. Please direct further ASP.NET inquiries there.

Regarding the logic - the "Remember Me" part of the login procedure should only be run if the login was successful. With two separate button handlers, it would get run regardless. The remember me code should go in the block that successfully logs in the user - just before the Response.Redirect call.
 
Andrzejek

Visual Studio (ASP.NET) uses both C# and VB.NET.
 
'The remember me code should go in the block that successfully logs in the user - just before the Response.Redirect call'.

That sounds logical now that you point it out. I will do that, and get rid of the second button.

OK, I will subscribe to the ASP.NET room here.

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top