473,699 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

'The name does not exist in the current context'

63 New Member
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 8304
Plater
7,872 Recognized Expert Expert
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.P age
Nov 11 '10 #2
MiziaQ
63 New Member
That got rid of the two errors - thanks! However, I now get a new error message.

'No overload for 'btnLogin_Authe nticate' matches delegate 'System.EventHa ndler'. Any ideas?

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


I would think you would need to use:
protected void btnLogin_Authen ticate(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 AuthenticateEve ntArgs, 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
4855
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 to copy databases. But this was not going to work since I have to hard code the database names in the package. Back to RTFMing, I discovered the Dynamic Properties Task. So now I setup a .bat file that calls dtsrun and via global variables...
4
1647
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 DataTable called dtPersons that loads all the data of the persons. I have a string variable called tableVariable that stores tha name "dtPersons".
6
23882
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 should magically be able to reference my strings using the syntax Resources.strings.string1. This isn't working for me. Is there something I'm missing other than moving the file itself and rebuilding? I get this error: "The type or namespace...
0
2183
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. What is the remedy - I wanna reuse this control on different pages. I beg for help. Eric
1
7502
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 context
2
9916
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
11628
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' does not exist in the current context". I don't know what to do about it. The field is there. It worked yesterday. Any ideas? HTML CODE: <%@ Master Language="C#" EnableTheming="false" AutoEventWireup="true"...
0
776
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 triggerred event in a such code: Private Sub dene(ByVal sender As Object, ByVal e As EventArgs) _ Handles btnOne.MouseHover, btnTwo.MouseHover Dim clickedCtrl As Control
4
10152
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 why? Please help!!
0
1450
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 context' I researched a web and found that similar problem exists around but somehow I cannot get solution. Interesting thing is that if do run debugging and ignore error
0
8615
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9173
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9033
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8882
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7748
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5872
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2009
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.