472,805 Members | 996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

The name 'UserName' does not exist in the current context"?

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" CodeFile="mp_Main.master.cs" Inherits="mp_Main" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>My Page</title>
<link rel="stylesheet" type="text/css" href="CSS/g-styles.css" />
</head>
<body>
<form id="frmMain" runat="server">
<asp:SiteMapDataSource ID="dsMySiteMap" runat="server"
ShowStartingNode="False" SiteMapProvider="MainMapProvider" />
<div id="g-wrapper">
<div id="h-wrapper">
<div id="h-head">
<div class="l-area">
<div class="l-column">
<div class="f-label">user name</div>
<div class="r-field" id="Div1">
<div class="f-field-left"></div>
<div class="f-field-center">
<asp:TextBox ID="UserName" runat="server"
CssClass="f-field"></asp:TextBox>
</div>
<div class="f-field-right"></div>
</div>
etc...

CODE BEHIND:
....
protected void btnLogin_Click(object sender, EventArgs e)
{
string sError = "";

if (UserName.Text == "")
{
sError = "True";
}
etc...
Thanks,
Michael
Oct 26 '06 #1
3 11535
There are a couple issues that could be happening. It could be that the
build of the page/site has failed without you knowing it so therefore when
it's executing the code the object isn't getting connected properly because
it doesn't know about it really (since the build process failed). Give a
quick rebuild and see if any errors pop up

Another thing could be the designer.cs file didn't update with the
information on the protected members (in the web application project).

See if it's able to work with this.UserName. Perhaps it's getting it
confused with a username property that could be available in one of the
namespaces (this one's a shot in the dark though).

--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
"Michael" <Mi*****@discussions.microsoft.comwrote in message
news:43**********************************@microsof t.com...
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" CodeFile="mp_Main.master.cs" Inherits="mp_Main" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>My Page</title>
<link rel="stylesheet" type="text/css" href="CSS/g-styles.css" />
</head>
<body>
<form id="frmMain" runat="server">
<asp:SiteMapDataSource ID="dsMySiteMap" runat="server"
ShowStartingNode="False" SiteMapProvider="MainMapProvider" />
<div id="g-wrapper">
<div id="h-wrapper">
<div id="h-head">
<div class="l-area">
<div class="l-column">
<div class="f-label">user name</div>
<div class="r-field" id="Div1">
<div class="f-field-left"></div>
<div class="f-field-center">
<asp:TextBox ID="UserName" runat="server"
CssClass="f-field"></asp:TextBox>
</div>
<div class="f-field-right"></div>
</div>
etc...

CODE BEHIND:
...
protected void btnLogin_Click(object sender, EventArgs e)
{
string sError = "";

if (UserName.Text == "")
{
sError = "True";
}
etc...
Thanks,
Michael

Oct 26 '06 #2
Mark,
thank you for the reply. First I cannot build the project without hitting
the error. The only way I have been able to build it is to comment out my
code. If I run the application in debug mode, and then when I get the error
just say to run the last good build I just say yes, it runs fine and also
hits all my new code as well as runs fine through the code that is suppose to
be giving the error. hmmm
Secondly, I tried what you said about the "this.UserName" but it did not
make any difference.

Any other thoughts?
Michael.

"Mark Fitzpatrick" wrote:
There are a couple issues that could be happening. It could be that the
build of the page/site has failed without you knowing it so therefore when
it's executing the code the object isn't getting connected properly because
it doesn't know about it really (since the build process failed). Give a
quick rebuild and see if any errors pop up

Another thing could be the designer.cs file didn't update with the
information on the protected members (in the web application project).

See if it's able to work with this.UserName. Perhaps it's getting it
confused with a username property that could be available in one of the
namespaces (this one's a shot in the dark though).

--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
"Michael" <Mi*****@discussions.microsoft.comwrote in message
news:43**********************************@microsof t.com...
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" CodeFile="mp_Main.master.cs" Inherits="mp_Main" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>My Page</title>
<link rel="stylesheet" type="text/css" href="CSS/g-styles.css" />
</head>
<body>
<form id="frmMain" runat="server">
<asp:SiteMapDataSource ID="dsMySiteMap" runat="server"
ShowStartingNode="False" SiteMapProvider="MainMapProvider" />
<div id="g-wrapper">
<div id="h-wrapper">
<div id="h-head">
<div class="l-area">
<div class="l-column">
<div class="f-label">user name</div>
<div class="r-field" id="Div1">
<div class="f-field-left"></div>
<div class="f-field-center">
<asp:TextBox ID="UserName" runat="server"
CssClass="f-field"></asp:TextBox>
</div>
<div class="f-field-right"></div>
</div>
etc...

CODE BEHIND:
...
protected void btnLogin_Click(object sender, EventArgs e)
{
string sError = "";

if (UserName.Text == "")
{
sError = "True";
}
etc...
Thanks,
Michael


Oct 26 '06 #3
Something else to try, open the master page, then switch back to design view
from html view. VS.Net has the nasty habbit of not noticing controls until
the page has been put into design view. Sometimes just toggling between the
views adds the appropriate reference and it will then work.

--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Michael" <Mi*****@discussions.microsoft.comwrote in message
news:F2**********************************@microsof t.com...
Mark,
thank you for the reply. First I cannot build the project without hitting
the error. The only way I have been able to build it is to comment out my
code. If I run the application in debug mode, and then when I get the
error
just say to run the last good build I just say yes, it runs fine and also
hits all my new code as well as runs fine through the code that is suppose
to
be giving the error. hmmm
Secondly, I tried what you said about the "this.UserName" but it did not
make any difference.

Any other thoughts?
Michael.

"Mark Fitzpatrick" wrote:
>There are a couple issues that could be happening. It could be that the
build of the page/site has failed without you knowing it so therefore
when
it's executing the code the object isn't getting connected properly
because
it doesn't know about it really (since the build process failed). Give a
quick rebuild and see if any errors pop up

Another thing could be the designer.cs file didn't update with the
information on the protected members (in the web application project).

See if it's able to work with this.UserName. Perhaps it's getting it
confused with a username property that could be available in one of the
namespaces (this one's a shot in the dark though).

--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
"Michael" <Mi*****@discussions.microsoft.comwrote in message
news:43**********************************@microso ft.com...
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" CodeFile="mp_Main.master.cs" Inherits="mp_Main"
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>My Page</title>
<link rel="stylesheet" type="text/css" href="CSS/g-styles.css" />
</head>
<body>
<form id="frmMain" runat="server">
<asp:SiteMapDataSource ID="dsMySiteMap" runat="server"
ShowStartingNode="False" SiteMapProvider="MainMapProvider" />
<div id="g-wrapper">
<div id="h-wrapper">
<div id="h-head">
<div class="l-area">
<div class="l-column">
<div class="f-label">user name</div>
<div class="r-field" id="Div1">
<div class="f-field-left"></div>
<div class="f-field-center">
<asp:TextBox ID="UserName" runat="server"
CssClass="f-field"></asp:TextBox>
</div>
<div class="f-field-right"></div>
</div>
etc...

CODE BEHIND:
...
protected void btnLogin_Click(object sender, EventArgs e)
{
string sError = "";

if (UserName.Text == "")
{
sError = "True";
}
etc...
Thanks,
Michael



Oct 26 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Alfred E Neuman | last post by:
I've read that... AClass ac = AClass( "name", 23 ); is less efficient than... AClass ac( "name", 23 ); because the first has to create a temporary object which is then assigned to ac. ...
4
by: alien2_51 | last post by:
Greetings, I apologize for the cross post I posted previously to .Net Framework with no replies... I have an application server that potentially will service all enterprise applications from...
0
by: Dirk Försterling | last post by:
Hi all, a few days ago, I upgraded from PostgreSQL 7.2.1 to 7.4, following the instructions in the INSTALL file, including dump and restore. All this worked fine without any error (message). ...
0
by: Smokey Grindle | last post by:
I am using of course the login membership manager in asp.net 2.0, and am using the loginname control to display the current login name logged in, however, I'd rather display the users "actual name"...
51
by: Tony Sinclair | last post by:
I'm just learning C#. I'm writing a program (using Visual C# 2005 on WinXP) to combine several files into one (HKSplit is a popular freeware program that does this, but it requires all input and...
8
MMcCarthy
by: MMcCarthy | last post by:
Hi everyone I had an interesting problem today with a client. I have set up security and privilege on a database depending on NT User Login. However, I've only just realised that the code...
2
by: shalong | last post by:
Hi all, VS 2008 is complaining that HttpWebRequest class is not in System.Net namespace I have referenced System.Net and have coded "using System.Net" I think its a setup problem rather than a...
3
by: =?Utf-8?B?Sm9obg==?= | last post by:
Hi, I use Session to save and pass values between pages, (please see the following). It works fine on my computer, but on the server, I launch the main page, wait for 20 minutes, and click a...
1
by: avecreep | last post by:
Hi, i was trying to find a web application and i found one open source on the internet. i put the code folders on the root folder and when i tried to acces via web browser it all worked fine ( i...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.