473,386 Members | 1,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

'The name does not exist in the current context'

63
I'm trying to authenticate the user login in c#. I get the following 2 errors: 'the name 'login_username' does not exist in the current context' and 'the name 'login_password' does not exist in the current context'.

index.aspx

Expand|Select|Wrap|Line Numbers
  1. <tr>
  2.                         <td>&nbsp;</td>
  3.                         <td>
  4.                             <asp:TextBox ID="login_username" runat="server" Width="160px"></asp:TextBox>
  5.                         </td>
  6.                         <td>
  7.                             <asp:TextBox ID="login_password" TextMode="password" runat="server" Width="160px"></asp:TextBox>
  8.                         </td>
  9.                         <td>
  10.                             <asp:Button id="btnLogin" class ="btn" Text="Login" onClick="btnLogin_Authenticate" runat="server" Width="50px" />
  11.                         </td>
  12.                     </tr>
  13.  
index.aspx.cs

Expand|Select|Wrap|Line Numbers
  1. protected void btnLogin_Authenticate(object sender, AuthenticateEventArgs e)
  2.     {
  3.  
  4.         try
  5.         {
  6.  
  7.             string username; //Get the email from the control
  8.             string password; //Get the password from the control
  9.  
  10.             username = login_username.Text;
  11.             password = login_password.Text;
  12.  
  13.             bool flag = AuthenticateUser(username, password);
  14.  
  15.             if (flag == true)
  16.             {
  17.  
  18.                 e.Authenticated = true;
  19.                 string randomString = Guid.NewGuid().ToString();
  20.  
  21.                 string url = "companyadmin.aspx?";
  22.                 url += randomString;
  23.                 Response.Redirect(url);
  24.  
  25.             }
  26.             else
  27.  
  28.                 e.Authenticated = false;
  29.                 Response.Redirect("~/loginattempt.aspx?retry");
  30.         }
  31.         catch (Exception)
  32.         {
  33.             e.Authenticated = false;
  34.  
  35.         }
  36.     }
  37.  
  38.  
Thanks in advance for the help!
Nov 11 '10 #1
3 8227
Plater
7,872 Expert 4TB
Do both of your files have matching names at the top of their contents?
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="index" %>

and

public partial class index: System.Web.UI.Page
Nov 11 '10 #2
MiziaQ
63
That got rid of the two errors - thanks! However, I now get a new error message.

'No overload for 'btnLogin_Authenticate' matches delegate 'System.EventHandler'. Any ideas?

I appreciate it!
Nov 12 '10 #3
Plater
7,872 Expert 4TB
Well I was wondering about that, I've never seen a button handler look like this:
protected void btnLogin_Authenticate(object sender, AuthenticateEventArgs e)


I would think you would need to use:
protected void btnLogin_Authenticate(object sender, EventArgs e)

That should match the expected handler for the button. I have no idea if e comes in as an instance of AuthenticateEventArgs, for me it is always a blank instance of EventArgs
Nov 12 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: CxG | last post by:
We need to copy about 25 databases whenever we get a new software delivery. Currently, the process is to manually use the DTS database copy wizard. Doing some research, I created a DTS package...
4
by: Lucas Sain | last post by:
Hi, I think thta for this I have to use reflection... but I'm not shure. How can I find/get an object at runtime by looking for its name that is stored in a variable. For example: I have a...
6
by: CuriousGeorge | last post by:
I've upgraded a .Net 1.1 web app to 2.0 and am having a heck of a time getting resources to work again. From what I understand if I move my strings.resx file into the App_GlobalResources folder I...
0
by: Eric | last post by:
This is a nightmare. I have my web user control and I dragged it into DIV on my .aspx page. It's just a panel with a few textboxes. When I try to access some textbox, the above error shows up....
1
by: Arjen | last post by:
Hi, I do this inside a repeater: <% if ((Boolean)((DataRowView)Container.DataItem) == true) { %> <%} %> I get this message: CS0103: The name 'Container' does not exist in the current...
2
by: Jeff | last post by:
hey asp.net 2.0 (C'#) In the code behind file I have this method: public String AddBR(Object param) { String text = (String) param; return text; }
3
by: Michael | last post by:
Hi, I am getting a strange error. Last night when I left work this was working perfectly. This morning when I try to run this code in VS2005, it comes up with an error saying "The name 'UserName'...
0
by: fnuran | last post by:
Hello, My name is Nuran and I am a new in TheScripts.com and a programmer on .NET and I am developing a VB.NET project with windows forms. I need to know how I can obtain the name of a current...
4
by: techguy78 | last post by:
Hi - I added a gridview to me aspx page and i 'm trying to assing data to it from codebehind. i'm getting this error.. The name 'Gridview1' does not exist in the current context Any idea...
0
by: Terry | last post by:
Hello, I have problem adding controls to my webpage default.aspx. There is a group of controls that just refuse to be used with message: 'The name 'controlname' does not exist in the current...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.