473,386 Members | 1,647 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.

Control does not exist in the current context

26
G'day,

I have encontered what appears to be a common problem, but unfortunately the typical solution i have found has not worked for me.

I have just copied the files from an "ASP .NET Web Site" to an "ASP .NET Web Application" because i have learned about the differences and have decided to move to the latter. I simply copied and pasted all the .aspx (with respective .aspx.cs code-behind files) and some other files such as scripts etc into the "Web Application". I have also added the same references to class libraries I had in the "Web Site".

When I come to compile the "Web Application", I get errors saying that controls "cannot be found in the current context". I did not get these errors in the "Web Site" and the common problem apparently is that there are backup files or duplicate partial classes, which i'm certain is not the case for me...

One example is that I have an ASP:PlaceHolder in header.aspx as follows...

<asp:Placeholder runat="server" ID="headermenuholder">

...but i get the error "The name 'headermenuholder' does not exist in the current context"

I would be VERY greatful if someone could give me their opinion! :)

Best Regards,
Chris
Jul 4 '09 #1
6 28392
cbellew
26
Sorted.

Turned out i wasn't aware that in "ASP .NET Web Application" projects there needed to be both .cs and .designer for each page. I created a new page by going to add item and the correct .designer page was created, so i copied the code from the old version, deleted the old version and recompiled and it worked!

Thanks anyway :)
Jul 4 '09 #2
cbellew
26
Even Better!

Right click on the file and choose "Convert to Web Application" - feel a bit silly now!

Thanks
Jul 4 '09 #3
ok, u got it, and nice to share with us
Jul 5 '09 #4
Even silly things are great for unknown like me ... Thanks a lot .. I too had probelm in converting the website to web project

Thanks to cebellew !!!
Nov 11 '09 #5
Frinavale
9,735 Expert Mod 8TB
It's good to know how you solved your solution.
I didn't realize that you can see this error in the case when the .designer file is missing (normally this file isn't missing because it's typically automatically generated for you by Visual Studio....I can see how it would be a problem if it were missing).

Usually when this type of error shows up someone is trying to use something that they aren't allowed to use in the Global.asax file.

Well, at least that's when I encountered this error.

The Global.asax file is a tricky thing. In some methods things like Session are available and then in other methods it is not. It's a little confusing when you first start using the Global.asax but once you realize what it's for things start making sense.

-Frinny
Nov 11 '09 #6
HA! hours of messing about was driving me to drink. literally.

Rightclick project, convert to web application.

Done deal.

Thanks cbellew.
Oct 21 '10 #7

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

Similar topics

2
by: aarepasky | last post by:
I am using ASP Web 2005 express and I have a textbox in a user control. Now when I try to use it in another user control, I get the error that it "does not exist in current context. These 2 user...
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; }
2
by: The.Relinator | last post by:
Hello, I seem to be getting the following error in one class, but not in a form. The name 'Invoke' does not exist in the current context. The code I am trying to execute is: Invoke(d, new...
5
by: nudrat | last post by:
I included a control TextBox with 'txtError' name. whenever I build this I get this error. The name 'txtError' does not exist in the current context But its running on last successful Build. I...
0
by: Dave | last post by:
I have an ASPX page that I can't seem to do anything with the dropdowns. The error that I'm getting is "The name 'EmployeeDropdownList' does not exist in the current context. I have all the...
2
by: =?Utf-8?B?QyNub3ZpY2U=?= | last post by:
Like my name says I am a total novice at C#. I am trying to following examples in a book that I have but unfortunately they do not provide you with code for the whole project. Up till now I could...
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...
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...
3
by: MiziaQ | last post by:
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...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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,...
0
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...

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.