The name <> does not exist in the current context

 I was working on the project, i received the error
 
The name <<xyz>> does not exist in the current context
 
I tried my best to find the core issue, but was unable to locate it.
 
After struggling thru internet, i found the reason behind the issue.
 
 
How Issue Occured ?
 
What i did was, I was in no mood of creating the 2nd page that is similar to my 1st page. I copied the 1st page (say page1.aspx) and pasted it and renamed it to page2.aspx.
 
I did some changes on the page2.aspx, adding and removing controls.
 
When i started debugging, i received the error
 
“The name txtUsername.text does not exist in the current context.”
 


 
What is the Solution ?
 
The solution is,
 
You have to confirm the aspx page and its codebehind page ( eg : for page1.aspx it should be page2.aspx.cs, for page2.aspx it should be page2.aspx.cs )
 
similarly
 
You have to confirm the class name of the aspx page and codebehind page.
( eg :
1. In page1.aspx file, class name is define by Inherits=”page1″ ,
2. In code behind file page1.aspx.cs it should mention as
public partial class page1 : System.Web.UI.Page
)
 
 
What i found was, i was using the page1 classname in page2.
Changing this, solved my issue.
 
Hope this helps you too….
 
If YES, please share your happiness by give us your reply.


by admin on June 13th, 2009 in ASP.Net

There are no comments.

Name*: Website: E-Mail*:
XHTML: You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>