I add a label to a page and set its ID to LabelEditMessage and debug, and there it is. Then in the code behind page (C#) I add a line of code LabelEditMessage.Text="test"; If I build, the build succeeds, but if I press the debug button it does another
build that fails and tells me that LabelEditMessage Does Not Exist in the Current Context. Intellisense knows about it, and I use that to enter the reference to be sure I am not mispelling.
So I tried using FindControl, and that fails with a null reference. It is there, I can see it, but Visual Web Developer refuses to acknowledge it's existence in the code behind file. If I remove the code reference it builds fine and I can see the label
with its default value when i debug, but I cannot reference the label in code.
I'm stumped. It's such a simple thing that I have done many times before. I just don't know what else to try.
I had an almost identical problem once before in the page load event trying to set the ConnectionString property of an SqlDataSource. I tried everything I could think of for days. Then one day I deleted a validator element and it suddenly started working,
and I replaced the validator and it kept on working, so I dismissed it as a fluke. But now it is back, only this time with a label rather than an SqlDataSource. Naturally, I deleted the validator element from the page again, but this time it did not make
the problem go away.
I've tried a number of variations, including setting the lable text in the page load event, but this is what I have currently, which is in a RowUpdating event of a GridView control. First the code file:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
If I remove the reference to the label so the build will succeed and set a break point at that spot in the code, then when I hit the breakpoint I can see the label in the local variable panel and change its text property and it shows up on the page and works
fine. So it is definitely defined in that context. The error message is wrong. I think this has to be a bug or something corrupted.
I think I figured this out by myself, so I thought I should post and share in case it might help somebody else one day.
I discovered that if I simply used VWD as an editor and save my changes and then go pull up the pages in a web browser without trying to debug or "start without debug" from the IDE then the extra build done prior to a debug was not attempted, thus did not fail,
and the page loaded and worked normally from outside of VWD.
Then I found an option to turn off the build prior to debug in VWD, so now it all works like it should by skipping that final build.
Here is my theory on why this is so. I believe that once the page has been displayed in a browser, the assembly's .dll file has been loaded into memory by IIS and is thus marked as in use and only IIS can unloaded it and recompile and load a fresh copy. If
VWD does a build for a debug run that tries to replace the dll it cannot do so, and is working with an older version in memory vs newer modified source code. That explains why I could build from the build menu in VWD successfully, but the build done in prep
for a debug was not successful because that build tried to replace a dll file in use by IIS. Just changing the source file and letting IIS discover the change and recompile dynamically caused IIS to unload and reload the dll, which is the only way it could
work once IIS had originally loaded it. So this problem may not occur when using the web server that comes with VWD, and it definitely does not occur if you turn of the build.
Moral of the story: If you are testing in IIS, you should go to the website menu in VWD, click start options, click "build" on the tree in the left pane, and on the dropdown list labelled "Before running startup page" select "No Build". Works for me.
I guess you can say this post has helped one more person. I was baffled why I could not figure out what happened. I even went through all of the temporary asp.net files looking for a reason.
I sincerly appreciate you sharing this information - cheers!
well, i had the same problem... but here is my situation and the solution: i had a file called details.aspx which was using details.aspx.cs as the code file. As soon I have created this file i said maybe i will use the layout later so i just copy-paste and
rename it as template.aspx. I continued my work on details.aspx by adding textboxes, labels etc... and methods in the .cs file. but on "Build" stage i got the magic error "The name xxx Does Not Exist in the Current Context". Reason: i was using the same .cs
file name for both template.aspx and details.aspx, but the controls were only on the details.aspx... I can imagine how confuse was the compiler... so i changed the .cs file name for the template.aspx and all build up successfully...
Thanks for this post. I too had multiple aspx files referencing the same code behind file. I was trying to add a button to one of my aspx files and I kept getting the Does Not Exist in Current Context error. Once I excluded my other aspx files from the
IDE everything compiled. Thanks again.
I am quite new to Visual Studio 2005, and I am having a similar issue. However it is not caused by repeating names in the solution. I have renamed the offending Textbox to ridiculous names and it still gives me the does not exist in the current Context error.
The truly strange thing to me is that there are other text fields there that are working perfectly, it is only when I am now adding new fields to this update panel. If I create a new textbox and call it by an exiting ID's name, and remove the old textbox
it still works. But If I change the ID to what I want to use, or "ABC123" then it is out of context.
Never mind, I found the issue. I had a backup copy of my aspx in the solution, and I assume when the compiler ran it was reading the back up first, and not the one I am working with.
One of our developers wanted a master page that was just like the original site master, but he removed some items from the aspx page, but pointed the code behind file to be that of masterpage1, instead of having a separate codebase to keep up with. The
problem arised when a control was added to masterpage1, and was referenced in the code behind, the compiler stated that the item was not referenced, but didn't tell us that it was masterpage2 that was the problem.
So the fix here is to add the same control to both masterpages, or get mastepage1 to do what masterpage2 does, and delete masterpage2.
Changing the build option to none will work until you hit a page that references masterpage2.
Yup, that was the problem! Thank you for this post! It's funny that the one marked as the solution is a cop-out, it's not the real solution. I copied and pasted multiple aspx files and renamed them but failed to realize that they were all referencing/inheriting
the same class! So the compiler was reading a page that didn't have the new controls first. This is truly an important post, and thank you for posting that solution. I was so confused and didn't want to go with the post marked as "answer" in this thread
because that's just not good enough. Thank you! You've saved me tons of time!!
Since then i have been working in backend components such as C#.NEt, SQL Server 2005, WebServices, WCF.
Today when i am going through a tutorial of implementiong Login Control and LoginView Control, I am not able to build my code and getting same error as said in this forum.
I have downloaded the code from this tutorial: http://www.asp.net/learn/security/tutorial-02-cs.aspx
Although i am using a master page but i checked that all aspx pages are referring there individual code behind files.
Since then i have been working in backend components such as C#.NEt, SQL Server 2005, WebServices, WCF.
Today when i am going through a tutorial of implementiong Login Control and LoginView Control, I am not able to build my code and getting same error as said in this forum.
I have downloaded the code from this tutorial: http://www.asp.net/learn/security/tutorial-02-cs.aspx
Although i am using a master page but i checked that all aspx pages are referring there individual code behind files.
I fixed this by doing a search accross the entire solutio for the namespace and class name. I found some files that had been copied. They were causing duplication when the web site project compiled. Deleting them fixed the issue.
One of our developers wanted a master page that was just like the original site master, but he removed some items from the aspx page, but pointed the code behind file to be that of masterpage1, instead of having a separate codebase to keep up with. The
problem arised when a control was added to masterpage1, and was referenced in the code behind, the compiler stated that the item was not referenced, but didn't tell us that it was masterpage2 that was the problem.
So the fix here is to add the same control to both masterpages, or get mastepage1 to do what masterpage2 does, and delete masterpage2.
Changing the build option to none will work until you hit a page that references masterpage2.
This solved my problem! I had created an admin.master by doing a file saveas on each of my main master files (aspx / cs) and I had the admin pointing at the main master codebehind. Worked fine until I added some public properties and tried to get to the
alt tags of some of the images!
I had made a backup of my aspx and aspx.cs files in the same folder. Thus it was giving me that error. When i deleted those 2 files i stopped getting the compiler/build error.
OK, this is not the whole picture.
As for me (VS2005), I had only one pair of Default.aspx and Default.aspx.cs
just for some testing purpose. It worked OK until certain moment.
I did something and since then started to get this compilation error.
Yes, casting thing like: Label lb = (Label)Page.FindControl("form1")... does work, but nothing else.
And then by accident I discovered that VS2005 by default generates DLLs
and put them in some folder like: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\ccd7038d\1778aef7\assembly\dl3\8d7ee5d1\de6c8a4c_8acec901\ (!?)
Maybe that was because I did not deploy my site(pages) onto the server.
Anyway, the point is that sometimes DLLs are not rebuilt, and
I found the whole bunch of these DLLs under the ..\root\ folder!
Can anyone comment on this?
I cleaned project and deleted all folders in the ..\roor\" folder.
And still have to use casting just to be able to compile the code.
...
P.S. OK, the mystery is solved. By mistake I deletedDefault.aspx.designer.cs file,
which contains definitions of all class members.
Check if you are pointing the same code behind file in two different apsx forms, i found this answer in another forum and solved my problem, when faced similar one.
W-H
Please remember to click “Mark as Answer” on the post that helps you,and to click “Unmark as Answer” if a marked post does not actually answer your question.
W-H
Please remember to click “Mark as Answer” on the post that helps you,and to click “Unmark as Answer” if a marked post does not actually answer your question.
Well, I am getting the same error message, but for a different reason.
- I tried the first suggestion above, change the build options. That did not work.
- I do not have any other copies of pages with the same names, so that rules that out.
I am reasonable certain my problem is because the upload control i am using (the control that generates the error message) is buried so far down in the templates of my GridView that simply putting the control name in the code behind does not fully address
it. When i put the fileupload, with this name outside of the GridView it works fine. But, when it is in the InsertItem template of one of the Fields, it generates this message.
I am hoping i just need to learn how to address the control properly in the code behind. Perhaps
I was correct, same problem but for a totally different reason. So, incase someone else runs into this issue, I will share what I learned.
I was on the right track that the issue was due to the FileUpload control being inside the DetailsView Control. This made it so that my code could not directly access the FileUpload. But, i was wrong, i could not fully qualify the name of the control to
access it like I used to in VB (VB2 through VB6). I needed to use the FindControl Method. For this, in my code behind, I created a new Control of the type FileUpload and set it equal to the one in my web page. Here is the csharp code i used
The syntax for including the control type in ( ) seemed a bit odd to me, but it works.
Now, in my code behind, whenever I needed info about the original control, I accessed it from FileLogo2Upload
I also had RadioButtons in the template in the DetailView, so I created a new control for each of them, using Find Control so i could access the info from the new control to see which was checked.
The id of the lbl cotrol must be different therefor it shows the error, to find this go to the code behind page and type the lebel name , it must nit be displayed..
Well, this problem seems to have a multitude of problems and solutions. Here's another one that may be indicative of others and hasn't been mentioned yet.
If you add a control INsomething.aspx where something.aspx.designer.cs also exists, you have to add the control in
something.aspx.designer.cs in the following manner
the other thing I noticed after wrestling with some of the suggested solutions is that if I don't open it as a project and I open it as a website in VS2008, it runs fine.
Read all the entries about duplicates in back up files and thought that's embarressing and was certain that wasn't my problem!
Do a find of the entire project to make sure!! Even though the name in the solution explorer is different,
it doesn't change it in the code behind file.
My errors were similar. I resolved them by using Visual Studio and viewing the suspect page in design view, then saving. It rewrote the designer.cs file and cleared up all the discrepancies.
Hi, I know there are a lot of posts here but I would just like to add my two cents. Had the same problem where the code behind could not find the controls on the aspx page. Found the designer.cs was missing. Resolved it by right-clicking on the project end
selecting 'Convert To Web Application'. Bingo! Hope this helps someone!
i'm new to visual studio 2010 and asp.net with c# and having the same problem. after wasting time in google and this forum and many try and error, i can fix this problem by renaming my page and removing other page using the same cs and it works for me..
i will try another solution at the next time..
I've been using VWDE for about 3 years and only in the last few months did this strange error (bug) begin to appear and cause me some wasted hours - your fix solved problem - many thanks - JL
THANK YOU SLASH84!!! I have been trying to fix this ALL DAY! Your post about back up files was my answer. I had two files that were in the same directory with (essentially) the same code. They were causing my problem as well.
An FYI for others with the same problem - I had this error thrown for every control on my web page each time it was used and then one other error - an AJAX control was not recognized. The dll was already in the references but the tagPrefix was missing
from the web.config. I got that line in the web.config and all errors went away. Problem with that one control escalated to problems with every other.
I want to thank you for the tip about having used the same .cs file as somewhere else in the file - cos that fixed my issue related to this!!
psatodten
well, i had the same problem... but here is my situation and the solution: i had a file called details.aspx which was using details.aspx.cs as the code file. As soon I have created this file i said maybe i will use the layout later so i just copy-paste and
rename it as template.aspx. I continued my work on details.aspx by adding textboxes, labels etc... and methods in the .cs file. but on "Build" stage i got the magic error "The name xxx Does Not Exist in the Current Context". Reason: i was using the same .cs
file name for both template.aspx and details.aspx, but the controls were only on the details.aspx... I can imagine how confuse was the compiler... so i changed the .cs file name for the template.aspx and all build up successfully...
Another cause of this is if you copy and paste code from an aspx page into another aspx page, the designer isn't aware of any new controls that have been pasted, even though they are seen by Intellisense - seems to be a bug to me. The soultion is to create
your control(s) in the aspx design screen and name them the same as any code you are pastting in, then paste in the code. This way the designer is aware of the control(s) and the code for them gets generated correctly in the designer.cs file.
this solved my problem. I had a file-old.aspx which was referencing file.aspx.cs causing trouble. I did a search to the entire solution and the culprit was found. I exclude the file instead of renaming it.
The name xxx Does Not Exist in the Current Context
None
0 Points
4 Posts
The name xxx Does Not Exist in the Current Context
Jul 09, 2006 04:49 PM|Tepi|LINK
I add a label to a page and set its ID to LabelEditMessage and debug, and there it is. Then in the code behind page (C#) I add a line of code LabelEditMessage.Text="test"; If I build, the build succeeds, but if I press the debug button it does another build that fails and tells me that LabelEditMessage Does Not Exist in the Current Context. Intellisense knows about it, and I use that to enter the reference to be sure I am not mispelling.
So I tried using FindControl, and that fails with a null reference. It is there, I can see it, but Visual Web Developer refuses to acknowledge it's existence in the code behind file. If I remove the code reference it builds fine and I can see the label with its default value when i debug, but I cannot reference the label in code.
I'm stumped. It's such a simple thing that I have done many times before. I just don't know what else to try.
I had an almost identical problem once before in the page load event trying to set the ConnectionString property of an SqlDataSource. I tried everything I could think of for days. Then one day I deleted a validator element and it suddenly started working, and I replaced the validator and it kept on working, so I dismissed it as a fluke. But now it is back, only this time with a label rather than an SqlDataSource. Naturally, I deleted the validator element from the page again, but this time it did not make the problem go away.
I'm stuck.
Anybody else ever observed a similar problem?
All-Star
15482 Points
6040 Posts
Re: The name xxx Does Not Exist in the Current Context
Jul 10, 2006 01:57 PM|Mikhail Arkhipov (MSFT)|LINK
------------------------------------------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.
None
0 Points
4 Posts
Re: The name xxx Does Not Exist in the Current Context
Jul 10, 2006 08:28 PM|Tepi|LINK
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class regGridSess : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.SqlDataSourceGrid.ConnectionString = "Dsn=MISDATA;uid="
+ Session["uid"].ToString()
+ ";pwd="
+ Session["pwd"].ToString();
Label bannerLabel = (Label)Master.FindControl("bannerText");
bannerLabel.Text = "Registrations for a Session";
if (!IsPostBack) return; // First time in page code.
// Form has been posted.
}
protected void Button1_Click(object sender, EventArgs e)
{
GridView1.Visible = true;
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
TextBox1.Text = TextBox1.Text.PadLeft(6, Char.Parse("0"));
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
LabelEditMessage.Text = "test";
e.Cancel = true;
}
}
Here is the ASP source:
<%@ Page Language="C#" MasterPageFile="~/MISDefault.master" AutoEventWireup="true" CodeFile="regGridSess.aspx.cs" Inherits="regGridSess" Title="Registration Grid for a Session" %>
<asp:Content ID="Content1" ContentPlaceHolderID="mainContent" Runat="Server">
<asp:Label ID="Label1" runat="server" Text="Session Number:"></asp:Label><asp:TextBox
ID="TextBox1" runat="server" OnTextChanged="TextBox1_TextChanged"></asp:TextBox><asp:Button
ID="Button1" runat="server" OnClick="Button1_Click" Text="Show Registrations" />
<asp:RegularExpressionValidator
ID="sessNumValidator" runat="server" ControlToValidate="TextBox1" ErrorMessage="Session number must be one to 6 numeric digits"
ValidationExpression="\d{1,6}"></asp:RegularExpressionValidator>
<asp:SqlDataSource ID="SqlDataSourceGrid" runat="server" ConnectionString="<%$ ConnectionStrings:MisWeb %>"
DeleteCommand='DELETE FROM "Register" WHERE "Sess_Num" = ? AND "Ptcpnt_SSN" = ?'
InsertCommand='INSERT INTO "Register" ("Sess_Num", "Ptcpnt_SSN", "Credit_Type", "Pay_Code", "Stat", "ShowedUp", "Confirmation_Notice", "Fee_Stat", "Pay_Date", "Pay_Amt", "Credit_Hours", "District_PO", "Credit_Card_Num", "Credit_Card_Type", "Credit_Card_Name", "Credit_Card_Expiration", "Check_Num", "Cash_Rcpt_Num", "Cert_Printed", "Fee_Amt", "Refund_Amt", "Date_Billed", "Dist_Code", "Camp_Code", "Billing_Name", "Billing_Addr_Line_1", "Billing_Addr_Line_2", "Billing_City", "Billing_State", "Billing_Zip") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'
ProviderName="<%$ ConnectionStrings:MisWeb.ProviderName %>" SelectCommand='SELECT "Sess_Num", "Ptcpnt_SSN", "Credit_Type", "Pay_Code", "Stat", "ShowedUp", "Confirmation_Notice", "Fee_Stat", "Pay_Date", "Pay_Amt", "Credit_Hours", "Registration_Date", "District_PO", "Credit_Card_Num", "Credit_Card_Type", "Credit_Card_Name", "Credit_Card_Expiration", "Web_Registration", "Check_Num", "Cash_Rcpt_Num", "Cert_Printed", "Inv_WO", "Fee_Amt", "Refund_Amt", "Date_Billed", "Dist_Code", "Camp_Code", "DropCancel_Date", "Billing_Name", "Billing_Addr_Line_1", "Billing_Addr_Line_2", "Billing_City", "Billing_State", "Billing_Zip" FROM "Register" WHERE "Sess_Num" = ? '
UpdateCommand='UPDATE "Register" SET "Credit_Type" = ?, "Pay_Code" = ?, "Stat" = ?, "ShowedUp" = ?, "Confirmation_Notice" = ?, "Fee_Stat" = ?, "Pay_Date" = ?, "Pay_Amt" = ?, "Credit_Hours" = ?, "District_PO" = ?, "Credit_Card_Type" = ?, "Credit_Card_Name" = ?, "Credit_Card_Expiration" = ?, "Check_Num" = ?, "Cash_Rcpt_Num" = ?, "Cert_Printed" = ?, "Fee_Amt" = ?, "Refund_Amt" = ?, "Date_Billed" = ?, "Dist_Code" = ?, "Camp_Code" = ?, "Billing_Name" = ?, "Billing_Addr_Line_1" = ?, "Billing_Addr_Line_2" = ?, "Billing_City" = ?, "Billing_State" = ?, "Billing_Zip" = ? WHERE "Sess_Num" = ? AND "Ptcpnt_SSN" = ?'>
<DeleteParameters>
<asp:Parameter Name="Sess_Num" Type="String" />
<asp:Parameter Name="Ptcpnt_SSN" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Credit_Type" Type="String" />
<asp:Parameter Name="Pay_Code" Type="String" />
<asp:Parameter Name="Stat" Type="String" />
<asp:Parameter Name="ShowedUp" Type="String" />
<asp:Parameter Name="Confirmation_Notice" Type="String" />
<asp:Parameter Name="Fee_Stat" Type="String" />
<asp:Parameter Name="Pay_Date" Type="DateTime" />
<asp:Parameter Name="Pay_Amt" Type="Decimal" />
<asp:Parameter Name="Credit_Hours" Type="String" />
<asp:Parameter Name="District_PO" Type="String" />
<asp:Parameter Name="Credit_Card_Type" Type="String" />
<asp:Parameter Name="Credit_Card_Name" Type="String" />
<asp:Parameter Name="Credit_Card_Expiration" Type="String" />
<asp:Parameter Name="Check_Num" Type="String" />
<asp:Parameter Name="Cash_Rcpt_Num" Type="String" />
<asp:Parameter Name="Cert_Printed" Type="String" />
<asp:Parameter Name="Fee_Amt" Type="Decimal" />
<asp:Parameter Name="Refund_Amt" Type="Decimal" />
<asp:Parameter Name="Date_Billed" Type="DateTime" />
<asp:Parameter Name="Dist_Code" Type="String" />
<asp:Parameter Name="Camp_Code" Type="String" />
<asp:Parameter Name="Billing_Name" Type="String" />
<asp:Parameter Name="Billing_Addr_Line_1" Type="String" />
<asp:Parameter Name="Billing_Addr_Line_2" Type="String" />
<asp:Parameter Name="Billing_City" Type="String" />
<asp:Parameter Name="Billing_State" Type="String" />
<asp:Parameter Name="Billing_Zip" Type="String" />
<asp:Parameter Name="Sess_Num" Type="String" />
<asp:Parameter Name="Ptcpnt_SSN" Type="String" />
</UpdateParameters>
<SelectParameters>
<asp:ControlParameter ControlID="TextBox1" DefaultValue="000000" Name="Sess_Num"
PropertyName="Text" />
</SelectParameters>
<InsertParameters>
<asp:Parameter Name="Sess_Num" Type="String" />
<asp:Parameter Name="Ptcpnt_SSN" Type="String" />
<asp:Parameter Name="Credit_Type" Type="String" />
<asp:Parameter Name="Pay_Code" Type="String" />
<asp:Parameter Name="Stat" Type="String" />
<asp:Parameter Name="ShowedUp" Type="String" />
<asp:Parameter Name="Confirmation_Notice" Type="String" />
<asp:Parameter Name="Fee_Stat" Type="String" />
<asp:Parameter Name="Pay_Date" Type="DateTime" />
<asp:Parameter Name="Pay_Amt" Type="Decimal" />
<asp:Parameter Name="Credit_Hours" Type="String" />
<asp:Parameter Name="District_PO" Type="String" />
<asp:Parameter Name="Credit_Card_Num" Type="String" />
<asp:Parameter Name="Credit_Card_Type" Type="String" />
<asp:Parameter Name="Credit_Card_Name" Type="String" />
<asp:Parameter Name="Credit_Card_Expiration" Type="String" />
<asp:Parameter Name="Check_Num" Type="String" />
<asp:Parameter Name="Cash_Rcpt_Num" Type="String" />
<asp:Parameter Name="Cert_Printed" Type="String" />
<asp:Parameter Name="Fee_Amt" Type="Decimal" />
<asp:Parameter Name="Refund_Amt" Type="Decimal" />
<asp:Parameter Name="Date_Billed" Type="DateTime" />
<asp:Parameter Name="Dist_Code" Type="String" />
<asp:Parameter Name="Camp_Code" Type="String" />
<asp:Parameter Name="Billing_Name" Type="String" />
<asp:Parameter Name="Billing_Addr_Line_1" Type="String" />
<asp:Parameter Name="Billing_Addr_Line_2" Type="String" />
<asp:Parameter Name="Billing_City" Type="String" />
<asp:Parameter Name="Billing_State" Type="String" />
<asp:Parameter Name="Billing_Zip" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSourceCredit" runat="server" ConnectionString="<%$ ConnectionStrings:MisWeb %>"
ProviderName="<%$ ConnectionStrings:MisWeb.ProviderName %>" SelectCommand="SELECT [credit_type_code], [credit_type_descr] FROM [Credit_Type] WHERE ([Credit_Type_Active] = ?) ORDER BY [credit_type_code]">
<SelectParameters>
<asp:Parameter DefaultValue="Y" Name="Credit_Type_Active" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<asp:Label ID="LabelEditMessage" runat="server" ForeColor="Red" Width="1040px">xxx</asp:Label><br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White"
BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataKeyNames="Sess_Num,Ptcpnt_SSN"
DataSourceID="SqlDataSourceGrid" EmptyDataText="There are no data records to display."
GridLines="Vertical" Visible="False" AllowSorting="True" OnRowUpdating="GridView1_RowUpdating">
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="Sess_Num" HeaderText="Sess_Num" ReadOnly="True" SortExpression="Sess_Num" Visible="False" />
<asp:BoundField DataField="Ptcpnt_SSN" HeaderText="Ptcpnt_SSN" ReadOnly="True" SortExpression="Ptcpnt_SSN" />
<asp:TemplateField HeaderText="Credit_Type" SortExpression="Credit_Type">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList7" runat="server" DataSourceID="SqlDataSourceCredit"
DataTextField="credit_type_descr" DataValueField="credit_type_code" SelectedValue='<%# Bind("Credit_Type") %>'>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label7" runat="server" Text='<%# Bind("Credit_Type") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Pay_Code" SortExpression="Pay_Code">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList5" runat="server"
DataTextField="Pay_Code" DataValueField="Pay_Code" SelectedValue='<%# Bind("Pay_Code") %>'>
<asp:ListItem Selected="True" Value=" ">No Fee</asp:ListItem>
<asp:ListItem Value="D">District</asp:ListItem>
<asp:ListItem Value="I">Individual</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("Pay_Code") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Stat" SortExpression="Stat">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList6" runat="server"
DataTextField="Stat" DataValueField="Stat" SelectedValue='<%# Bind("Stat") %>'>
<asp:ListItem Selected="True" Value=" ">Unconfirmed</asp:ListItem>
<asp:ListItem Value="F">Confirmed</asp:ListItem>
<asp:ListItem Value="D">Dropped</asp:ListItem>
<asp:ListItem Value="C">Cancelled</asp:ListItem>
<asp:ListItem Value="L">Closed</asp:ListItem>
<asp:ListItem Value="W">Wait List</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("Stat") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ShowedUp" SortExpression="ShowedUp">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server"
DataTextField="ShowedUp" DataValueField="ShowedUp" SelectedValue='<%# Bind("ShowedUp") %>'>
<asp:ListItem Selected="True" Value="Y">Yes</asp:ListItem>
<asp:ListItem Value="N">No</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("ShowedUp") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Confirmation_Notice" SortExpression="Confirmation_Notice">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList2" runat="server"
DataTextField="Confirmation_Notice" DataValueField="Confirmation_Notice" SelectedValue='<%# Bind("Confirmation_Notice") %>'>
<asp:ListItem Selected="True" Value="Y">Yes</asp:ListItem>
<asp:ListItem Value="N">No</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Confirmation_Notice") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Fee_Stat" SortExpression="Fee_Stat">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList8" runat="server"
DataTextField="Fee_Stat" DataValueField="Fee_Stat" SelectedValue='<%# Bind("Fee_Stat") %>'>
<asp:ListItem Selected="True" Value="F">Free</asp:ListItem>
<asp:ListItem Value="R">Refund</asp:ListItem>
<asp:ListItem Value="P">Paid</asp:ListItem>
<asp:ListItem Value="B">Refund (Cancel)</asp:ListItem>
<asp:ListItem Value="T">Transfer</asp:ListItem>
<asp:ListItem Value="U">Unpaid</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label8" runat="server" Text='<%# Bind("Fee_Stat") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Pay_Date" HeaderText="Pay_Date" SortExpression="Pay_Date" />
<asp:BoundField DataField="Pay_Amt" HeaderText="Pay_Amt" SortExpression="Pay_Amt" />
<asp:BoundField DataField="Credit_Hours" HeaderText="Credit_Hours" SortExpression="Credit_Hours" />
<asp:BoundField DataField="Registration_Date" HeaderText="Registration_Date" SortExpression="Registration_Date" InsertVisible="False" ReadOnly="True" />
<asp:BoundField DataField="District_PO" HeaderText="District_PO" SortExpression="District_PO" />
<asp:BoundField DataField="Credit_Card_Num" HeaderText="Credit_Card_Num" SortExpression="Credit_Card_Num" Visible="False" />
<asp:BoundField DataField="Credit_Card_Type" HeaderText="Credit_Card_Type" SortExpression="Credit_Card_Type" />
<asp:BoundField DataField="Credit_Card_Name" HeaderText="Credit_Card_Name" SortExpression="Credit_Card_Name" />
<asp:BoundField DataField="Credit_Card_Expiration" HeaderText="Credit_Card_Expiration"
SortExpression="Credit_Card_Expiration" />
<asp:BoundField DataField="Web_Registration" HeaderText="Web_Registration" SortExpression="Web_Registration" InsertVisible="False" ReadOnly="True" />
<asp:BoundField DataField="Check_Num" HeaderText="Check_Num" SortExpression="Check_Num" />
<asp:BoundField DataField="Cash_Rcpt_Num" HeaderText="Cash_Rcpt_Num" SortExpression="Cash_Rcpt_Num" />
<asp:TemplateField HeaderText="Cert_Printed" SortExpression="Cert_Printed">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList3" runat="server"
DataTextField="Cert_Printed" DataValueField="Cert_Printed" SelectedValue='<%# Bind("Cert_Printed") %>'>
<asp:ListItem Selected="True" Value="Y">Yes</asp:ListItem>
<asp:ListItem Value="N">No</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("Cert_Printed") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Inv_WO" HeaderText="Inv_WO" SortExpression="Inv_WO" InsertVisible="False" ReadOnly="True" />
<asp:BoundField DataField="Fee_Amt" HeaderText="Fee_Amt" SortExpression="Fee_Amt" />
<asp:BoundField DataField="Refund_Amt" HeaderText="Refund_Amt" SortExpression="Refund_Amt" />
<asp:BoundField DataField="Date_Billed" HeaderText="Date_Billed" SortExpression="Date_Billed" />
<asp:BoundField DataField="Dist_Code" HeaderText="Dist_Code" SortExpression="Dist_Code" />
<asp:BoundField DataField="Camp_Code" HeaderText="Camp_Code" SortExpression="Camp_Code" />
<asp:BoundField DataField="DropCancel_Date" HeaderText="DropCancel_Date" SortExpression="DropCancel_Date" InsertVisible="False" ReadOnly="True" />
<asp:BoundField DataField="Billing_Name" HeaderText="Billing_Name" SortExpression="Billing_Name" />
<asp:BoundField DataField="Billing_Addr_Line_1" HeaderText="Billing_Addr_Line_1"
SortExpression="Billing_Addr_Line_1" />
<asp:BoundField DataField="Billing_Addr_Line_2" HeaderText="Billing_Addr_Line_2"
SortExpression="Billing_Addr_Line_2" />
<asp:BoundField DataField="Billing_City" HeaderText="Billing_City" SortExpression="Billing_City" />
<asp:BoundField DataField="Billing_State" HeaderText="Billing_State" SortExpression="Billing_State" />
<asp:BoundField DataField="Billing_Zip" HeaderText="Billing_Zip" SortExpression="Billing_Zip" />
</Columns>
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="Gainsboro" />
</asp:GridView>
</asp:Content>
None
0 Points
4 Posts
Re: The name xxx Does Not Exist in the Current Context
Jul 13, 2006 11:17 PM|Tepi|LINK
If I remove the reference to the label so the build will succeed and set a break point at that spot in the code, then when I hit the breakpoint I can see the label in the local variable panel and change its text property and it shows up on the page and works fine. So it is definitely defined in that context. The error message is wrong. I think this has to be a bug or something corrupted.
None
0 Points
4 Posts
Re: The name xxx Does Not Exist in the Current Context
Jul 21, 2006 07:16 PM|Tepi|LINK
I discovered that if I simply used VWD as an editor and save my changes and then go pull up the pages in a web browser without trying to debug or "start without debug" from the IDE then the extra build done prior to a debug was not attempted, thus did not fail, and the page loaded and worked normally from outside of VWD.
Then I found an option to turn off the build prior to debug in VWD, so now it all works like it should by skipping that final build.
Here is my theory on why this is so. I believe that once the page has been displayed in a browser, the assembly's .dll file has been loaded into memory by IIS and is thus marked as in use and only IIS can unloaded it and recompile and load a fresh copy. If VWD does a build for a debug run that tries to replace the dll it cannot do so, and is working with an older version in memory vs newer modified source code. That explains why I could build from the build menu in VWD successfully, but the build done in prep for a debug was not successful because that build tried to replace a dll file in use by IIS. Just changing the source file and letting IIS discover the change and recompile dynamically caused IIS to unload and reload the dll, which is the only way it could work once IIS had originally loaded it. So this problem may not occur when using the web server that comes with VWD, and it definitely does not occur if you turn of the build.
Moral of the story: If you are testing in IIS, you should go to the website menu in VWD, click start options, click "build" on the tree in the left pane, and on the dropdown list labelled "Before running startup page" select "No Build". Works for me.
Keith
Member
115 Points
155 Posts
Re: The name xxx Does Not Exist in the Current Context
Sep 14, 2006 11:27 PM|justinsaraceno|LINK
None
0 Points
1 Post
Re: The name xxx Does Not Exist in the Current Context
May 17, 2007 09:34 AM|digi dave|LINK
cheers Tepi for posting the fix - just had a very confusing 30 minutes with the same prob - turning build off sorted it.....
None
0 Points
14 Posts
Re: The name xxx Does Not Exist in the Current Context
Jun 01, 2007 08:26 PM|doWhileSomething|LINK
I guess you can say this post has helped one more person. I was baffled why I could not figure out what happened. I even went through all of the temporary asp.net files looking for a reason.
I sincerly appreciate you sharing this information - cheers!
None
0 Points
2 Posts
Re: The name xxx Does Not Exist in the Current Context
Jun 11, 2007 07:26 PM|psatodten|LINK
well, i had the same problem... but here is my situation and the solution: i had a file called details.aspx which was using details.aspx.cs as the code file. As soon I have created this file i said maybe i will use the layout later so i just copy-paste and rename it as template.aspx. I continued my work on details.aspx by adding textboxes, labels etc... and methods in the .cs file. but on "Build" stage i got the magic error "The name xxx Does Not Exist in the Current Context". Reason: i was using the same .cs file name for both template.aspx and details.aspx, but the controls were only on the details.aspx... I can imagine how confuse was the compiler... so i changed the .cs file name for the template.aspx and all build up successfully...
None
0 Points
1 Post
Re: The name xxx Does Not Exist in the Current Context
Jul 09, 2007 08:11 AM|jjstewar|LINK
Thanks for this post. I too had multiple aspx files referencing the same code behind file. I was trying to add a button to one of my aspx files and I kept getting the Does Not Exist in Current Context error. Once I excluded my other aspx files from the IDE everything compiled. Thanks again.
None
0 Points
2 Posts
Re: The name xxx Does Not Exist in the Current Context
Jul 20, 2007 12:28 PM|Ken_Walsh|LINK
I am quite new to Visual Studio 2005, and I am having a similar issue. However it is not caused by repeating names in the solution. I have renamed the offending Textbox to ridiculous names and it still gives me the does not exist in the current Context error.
The truly strange thing to me is that there are other text fields there that are working perfectly, it is only when I am now adding new fields to this update panel. If I create a new textbox and call it by an exiting ID's name, and remove the old textbox it still works. But If I change the ID to what I want to use, or "ABC123" then it is out of context.
Has anyone come across this before?
None
0 Points
2 Posts
Re: The name xxx Does Not Exist in the Current Context
Jul 20, 2007 01:33 PM|Ken_Walsh|LINK
Never mind, I found the issue. I had a backup copy of my aspx in the solution, and I assume when the compiler ran it was reading the back up first, and not the one I am working with.
Sorry about that.
Ken
Member
10 Points
4 Posts
Re: The name xxx Does Not Exist in the Current Context
Aug 13, 2007 12:50 PM|devThis|LINK
We just had a similar problem.
One of our developers wanted a master page that was just like the original site master, but he removed some items from the aspx page, but pointed the code behind file to be that of masterpage1, instead of having a separate codebase to keep up with. The problem arised when a control was added to masterpage1, and was referenced in the code behind, the compiler stated that the item was not referenced, but didn't tell us that it was masterpage2 that was the problem.
So the fix here is to add the same control to both masterpages, or get mastepage1 to do what masterpage2 does, and delete masterpage2.
Changing the build option to none will work until you hit a page that references masterpage2.
Member
5 Points
71 Posts
Re: The name xxx Does Not Exist in the Current Context
Sep 21, 2007 11:35 AM|Gewgala|LINK
Yup, that was the problem! Thank you for this post! It's funny that the one marked as the solution is a cop-out, it's not the real solution. I copied and pasted multiple aspx files and renamed them but failed to realize that they were all referencing/inheriting the same class! So the compiler was reading a page that didn't have the new controls first. This is truly an important post, and thank you for posting that solution. I was so confused and didn't want to go with the post marked as "answer" in this thread because that's just not good enough. Thank you! You've saved me tons of time!!
Member
14 Points
56 Posts
Re: The name xxx Does Not Exist in the Current Context
Apr 18, 2008 03:29 PM|bradwoody|LINK
Ken,
How embarrassing! I, too, had a backup copy of my aspx in the solution, and this was giving me the error.
I tried all the other suggestions posted here, but none worked. The instant I saw yours I cringed, knowing that was it for me, too.
Thanks,
Brad
None
0 Points
3 Posts
The name 'DataAccess' does not exist in the current context
May 15, 2008 11:24 AM|rajendrasedhain|LINK
using
System;using
System.Data;using
System.Configuration;using
System.Web;using
System.Web.Security;using
System.Web.UI;using
System.Web.UI.WebControls;using
System.Web.UI.WebControls.WebParts;using
System.Web.UI.HtmlControls; using System.Data.SqlClient;public
partial class _Default : System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e){
}
private void GridViewBind(){
try{
String repository = ""; Boolean first = false; String creatorType = "";{
if (reposotoryCheckBoxList.Items[i].Selected == true){
if (first == false){
repository = reposotoryCheckBoxList.Items[i].Value.ToString();
first = true;}
else{
repository = repository + " , " + reposotoryCheckBoxList.Items[i].Value.ToString();}
}
if (nameCheckBox.Items[i].Selected == true){
if (first == false){
creatorType = nameCheckBox.Items[i].Value.ToString();
first = true;}
else{
creatorType = creatorType + " , " + nameCheckBox.Items[i].Value.ToString();}
}
}
ds =
DataAccess.GetReport(repository,creatorType,nameTextBox.Text,titleTextBox.Text,subjectTextBox.Text); DataView dv = new DataView(ds.Tables[0]);GridView1.DataSource = ds.Tables[0];
GridView1.DataSourceID = string.Empty;GridView1.DataBind();
}
{
Response.Write(ex.Message.ToString());
//Response.Write(ex.StackTrace.ToString());Response.End();
}
finally{
}
}
protected void Button1_Click(object sender, EventArgs e){
//for (int i = 0; i <= reposotoryCheckBoxList.Items.Count - 1; i++) //{ // if (reposotoryCheckBoxList.Items[i].Selected == false && nameCheckBox.Items[i].Selected == false) // { // if (titleTextBox.Text == null + subjectTextBox.Text == null) // { // Response.Write("Enter value/select at least one field"); // } // } //}GridViewBind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e){
//GridViewBind();GridView1.PageIndex = e.NewPageIndex;
//GridView1.DataBind();}
}
public static SqlDataReader GetDetail(String ID){
}
{
return ConfigurationManager.ConnectionStrings["IA_ArchonConnectionString"].ToString();}
If anybody have the idea,why this error ? Please let me know.
Thank you in advance.
-Raj
Member
1 Points
13 Posts
Re: The name xxx Does Not Exist in the Current Context
Jun 16, 2008 09:05 AM|sunit_82|LINK
Thanx a lot for this solutions. I found this whole post ,specially ur reply very usefull.
Thanx again.!!!!!!!!!!!!!!!!!!
Does Not Exist in the Current Context
None
0 Points
10 Posts
Re: The name xxx Does Not Exist in the Current Context
Jul 14, 2008 01:53 AM|jbrune|LINK
Thank you for finding the answer to this. The problem still exists, using VWD 2005 sp1.
Member
1 Points
8 Posts
Re: The name xxx Does Not Exist in the Current Context
Aug 29, 2008 01:44 PM|anugrah.17|LINK
Hi All,
I worked in ASP.NET around 2 years back.
Since then i have been working in backend components such as C#.NEt, SQL Server 2005, WebServices, WCF.
Today when i am going through a tutorial of implementiong Login Control and LoginView Control, I am not able to build my code and getting same error as said in this forum.
I have downloaded the code from this tutorial: http://www.asp.net/learn/security/tutorial-02-cs.aspx
Although i am using a master page but i checked that all aspx pages are referring there individual code behind files.
Can anyone please suggest me what to do?
Member
1 Points
8 Posts
Re: The name xxx Does Not Exist in the Current Context
Aug 29, 2008 01:46 PM|anugrah.17|LINK
Hi All,
I worked in ASP.NET around 2 years back.
Since then i have been working in backend components such as C#.NEt, SQL Server 2005, WebServices, WCF.
Today when i am going through a tutorial of implementiong Login Control and LoginView Control, I am not able to build my code and getting same error as said in this forum.
I have downloaded the code from this tutorial: http://www.asp.net/learn/security/tutorial-02-cs.aspx
Although i am using a master page but i checked that all aspx pages are referring there individual code behind files.
Can anyone please suggest me what to do?
None
0 Points
4 Posts
Re: The name xxx Does Not Exist in the Current Context
Sep 10, 2008 02:07 PM|nehaljain|LINK
I had the same error. when i added one line in global.asax. I gave fully qualified name for the class and it was solved. [:)]
So instead of using
RemotingConfiguration.Configure(AppDomain.CurrentDomain.BaseDirectory + "remoteclient.config", true);
I used the fully qualified name as shown below.
System.Runtime.Remoting.
RemotingConfiguration.Configure(AppDomain.CurrentDomain.BaseDirectory + "remoteclient.config", true);All-Star
15482 Points
6040 Posts
Re: The name xxx Does Not Exist in the Current Context
Sep 10, 2008 03:51 PM|Mikhail Arkhipov (MSFT)|LINK
Adding
using System.Runtime.Remoting;
would help :)
------------------------------------------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.
None
0 Points
9 Posts
Re: The name xxx Does Not Exist in the Current Context
Dec 03, 2008 06:39 PM|baileyjames|LINK
I fixed this by doing a search accross the entire solutio for the namespace and class name. I found some files that had been copied. They were causing duplication when the web site project compiled. Deleting them fixed the issue.
None
0 Points
28 Posts
Re: The name xxx Does Not Exist in the Current Context
Jan 26, 2009 06:05 PM|mombassa|LINK
All-Star
39486 Points
8916 Posts
Re: The name xxx Does Not Exist in the Current Context
Feb 02, 2009 05:56 AM|rtpHarry|LINK
This solved my problem! I had created an admin.master by doing a file saveas on each of my main master files (aspx / cs) and I had the admin pointing at the main master codebehind. Worked fine until I added some public properties and tried to get to the alt tags of some of the images!
Thanks!
Member
5 Points
38 Posts
Re: The name xxx Does Not Exist in the Current Context
Mar 24, 2009 07:14 AM|thuyaaung7|LINK
Guys,
What you can try is Exclude the error page from project. Build the site. Include the page again. And build for second time.
It works for me.
None
0 Points
4 Posts
Re: The name xxx Does Not Exist in the Current Context
Apr 03, 2009 05:36 AM|slash84|LINK
I had made a backup of my aspx and aspx.cs files in the same folder. Thus it was giving me that error. When i deleted those 2 files i stopped getting the compiler/build error.
None
0 Points
31 Posts
Re: The name xxx Does Not Exist in the Current Context
Apr 03, 2009 12:46 PM|raviparams|LINK
It gives answer to me as well. Actually i do have the copy of the file (i created). Once i deleted the copy file it works well.
None
0 Points
4 Posts
Re: The name xxx Does Not Exist in the Current Context
May 06, 2009 05:07 PM|konic|LINK
As for me (VS2005), I had only one pair of Default.aspx and Default.aspx.cs
just for some testing purpose. It worked OK until certain moment.
I did something and since then started to get this compilation error.
Yes, casting thing like:
Label lb = (Label)Page.FindControl("form1")... does work, but nothing else.
And then by accident I discovered that VS2005 by default generates DLLs
and put them in some folder like: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\ccd7038d\1778aef7\assembly\dl3\8d7ee5d1\de6c8a4c_8acec901\ (!?)
Maybe that was because I did not deploy my site(pages) onto the server.
Anyway, the point is that sometimes DLLs are not rebuilt, and
I found the whole bunch of these DLLs under the ..\root\ folder!
Can anyone comment on this?
Member
5 Points
71 Posts
Re: The name xxx Does Not Exist in the Current Context
May 06, 2009 07:39 PM|Gewgala|LINK
None
0 Points
4 Posts
Re: The name xxx Does Not Exist in the Current Context
May 06, 2009 08:24 PM|konic|LINK
And still have to use casting just to be able to compile the code.
...
P.S. OK, the mystery is solved. By mistake I deleted Default.aspx.designer.cs file,
which contains definitions of all class members.
None
0 Points
9 Posts
Re: The name xxx Does Not Exist in the Current Context
May 13, 2009 10:00 AM|Ramya N|LINK
Check if you are pointing the same code behind file in two different apsx forms, i found this answer in another forum and solved my problem, when faced similar one.
None
0 Points
3 Posts
Re: The name xxx Does Not Exist in the Current Context
Jul 01, 2009 04:54 PM|jtaylorwehco|LINK
Brad,
I found out that if you rename the .aspx and the .aspx.cs file, rebuild web site, and rename the files back to the originals, the error goes away.
- jtaylorwehco
Member
149 Points
117 Posts
Re: The name xxx Does Not Exist in the Current Context
Aug 17, 2009 01:41 AM|hellowahab|LINK
Let see if it works for me!
Please remember to click “Mark as Answer” on the post that helps you,and to click “Unmark as Answer” if a marked post does not actually answer your question.
Member
149 Points
117 Posts
Re: The name xxx Does Not Exist in the Current Context
Aug 17, 2009 01:47 AM|hellowahab|LINK
Let see if it works for me!
Please remember to click “Mark as Answer” on the post that helps you,and to click “Unmark as Answer” if a marked post does not actually answer your question.
Member
1 Points
10 Posts
Re: The name xxx Does Not Exist in the Current Context
Aug 19, 2009 01:23 AM|jcevans|LINK
Well, I am getting the same error message, but for a different reason.
- I tried the first suggestion above, change the build options. That did not work.
- I do not have any other copies of pages with the same names, so that rules that out.
I am reasonable certain my problem is because the upload control i am using (the control that generates the error message) is buried so far down in the templates of my GridView that simply putting the control name in the code behind does not fully address it. When i put the fileupload, with this name outside of the GridView it works fine. But, when it is in the InsertItem template of one of the Fields, it generates this message.
I am hoping i just need to learn how to address the control properly in the code behind. Perhaps
instead of
fupEventLogo.enabled = true;
I need something like
gvEventInformation.Field6LogoUploadFilename.InsertItemTemplate.fupEventLogo.enabled = true;
or close to that. (This example does not work, but i'll bet it is moving in the right direction!)
I will just keep trying variations until I get it or i successfully address in the controls collection
If you have any suggestions, i would love to hear them!
Jon
Member
1 Points
10 Posts
Re: The name xxx Does Not Exist in the Current Context
Aug 25, 2009 11:05 PM|jcevans|LINK
Hi,
I was correct, same problem but for a totally different reason. So, incase someone else runs into this issue, I will share what I learned.
I was on the right track that the issue was due to the FileUpload control being inside the DetailsView Control. This made it so that my code could not directly access the FileUpload. But, i was wrong, i could not fully qualify the name of the control to access it like I used to in VB (VB2 through VB6). I needed to use the FindControl Method. For this, in my code behind, I created a new Control of the type FileUpload and set it equal to the one in my web page. Here is the csharp code i used
FileUpload FileLogo2Upload = (FileUpload)dvEventInformation.FindControl("fupEventLogo");
The syntax for including the control type in ( ) seemed a bit odd to me, but it works.
Now, in my code behind, whenever I needed info about the original control, I accessed it from FileLogo2Upload
I also had RadioButtons in the template in the DetailView, so I created a new control for each of them, using Find Control so i could access the info from the new control to see which was checked.
Hope this helps someone
Jon
FindControl
Member
10 Points
14 Posts
Re: The name xxx Does Not Exist in the Current Context
Aug 27, 2009 10:29 AM|hellobiswa2001|LINK
The id of the lbl cotrol must be different therefor it shows the error, to find this go to the code behind page and type the lebel name , it must nit be displayed..
By : Biswa
None
0 Points
4 Posts
Re: The name xxx Does Not Exist in the Current Context
Aug 27, 2009 01:38 PM|CodePartizan|LINK
Well, this problem seems to have a multitude of problems and solutions. Here's another one that may be indicative of others and hasn't been mentioned yet.
If you add a control IN something.aspx where something.aspx.designer.cs also exists, you have to add the control in something.aspx.designer.cs in the following manner
of course replacing the control type with what you need.
(at least this works for me on VS2005 SP1)
Cheers,
Partizan
Member
7 Points
109 Posts
Re: The name xxx Does Not Exist in the Current Context
Aug 28, 2009 11:03 AM|ravensensei|LINK
the other thing I noticed after wrestling with some of the suggested solutions is that if I don't open it as a project and I open it as a website in VS2008, it runs fine.
None
0 Points
7 Posts
Re: The name xxx Does Not Exist in the Current Context
Oct 08, 2009 06:57 AM|UptownGirl|LINK
Read all the entries about duplicates in back up files and thought that's embarressing and was certain that wasn't my problem!
Member
1 Points
5 Posts
Re: The name xxx Does Not Exist in the Current Context
Oct 29, 2009 12:15 PM|sumanabk|LINK
Thank you so much for this post. I spent a good deal of time trying to figure out the problem before
I check on the forums. How silly of me..hehee..I had the back up copy too. Once I excluded everything
else worked fine. :)
None
0 Points
1 Post
Re: The name xxx Does Not Exist in the Current Context
Nov 14, 2009 05:04 PM|MargaritaRosa|LINK
Thank you jcevans this worked for me
None
0 Points
2 Posts
Re: The name xxx Does Not Exist in the Current Context
Jan 29, 2010 09:48 AM|akdevnet|LINK
amazing thanks....it helped me!!
None
0 Points
1 Post
Re: The name xxx Does Not Exist in the Current Context
Feb 02, 2010 07:57 AM|edalmasso|LINK
I love u!! u saved me like 29472938 hours of headache!!!
cheers
None
0 Points
1 Post
Re: The name xxx Does Not Exist in the Current Context
Apr 21, 2010 05:40 PM|ET_0520|LINK
My errors were similar. I resolved them by using Visual Studio and viewing the suspect page in design view, then saving. It rewrote the designer.cs file and cleared up all the discrepancies.
None
0 Points
16 Posts
Re: The name xxx Does Not Exist in the Current Context
May 10, 2010 08:25 AM|ian_c22|LINK
Hi, I know there are a lot of posts here but I would just like to add my two cents. Had the same problem where the code behind could not find the controls on the aspx page. Found the designer.cs was missing. Resolved it by right-clicking on the project end selecting 'Convert To Web Application'. Bingo! Hope this helps someone!
None
0 Points
10 Posts
Re: The name xxx Does Not Exist in the Current Context
May 11, 2010 01:00 AM|danielrp|LINK
i'm new to visual studio 2010 and asp.net with c# and having the same problem. after wasting time in google and this forum and many try and error, i can fix this problem by renaming my page and removing other page using the same cs and it works for me.. i will try another solution at the next time..
Thanx for sharing guys.. it help so much :D
None
0 Points
1 Post
Re: The name xxx Does Not Exist in the Current Context
May 26, 2010 10:10 AM|john859|LINK
Thanks for taking the time to write your post.
I've been using VWDE for about 3 years and only in the last few months did this strange error (bug) begin to appear and cause me some wasted hours - your fix solved problem - many thanks - JL
Member
77 Points
74 Posts
Re: The name xxx Does Not Exist in the Current Context
Jun 02, 2010 07:13 AM|dotnetguts|LINK
I have tried to figure out other way of fixing this problem.
Check out my blog.
http://dotnetguts.blogspot.com/2010/06/label-does-not-exist-in-current-context.html
http://dotnetguts.blogspot.com
Logon to
None
0 Points
1 Post
Re: The name xxx Does Not Exist in the Current Context
Jul 22, 2010 03:54 PM|patm300e|LINK
THANK YOU SLASH84!!! I have been trying to fix this ALL DAY! Your post about back up files was my answer. I had two files that were in the same directory with (essentially) the same code. They were causing my problem as well.
Visual Studio 2008 debugging Asp .net error
None
0 Points
1 Post
Re: The name xxx Does Not Exist in the Current Context
Aug 18, 2010 08:26 AM|TylerMan|LINK
An FYI for others with the same problem - I had this error thrown for every control on my web page each time it was used and then one other error - an AJAX control was not recognized. The dll was already in the references but the tagPrefix was missing from the web.config. I got that line in the web.config and all errors went away. Problem with that one control escalated to problems with every other.
Hope this helps;
Dave
Member
8 Points
52 Posts
Re: The name xxx Does Not Exist in the Current Context
Oct 27, 2010 03:49 AM|AdmiralGanja|LINK
Well, my solution was to check my designer file. The name was wrong here...
Anyways... /J
None
0 Points
2 Posts
Re: The name xxx Does Not Exist in the Current Context
Nov 10, 2010 02:00 AM|jigs.patelit|LINK
thankx... i have same problem and solve in the same manner
Member
11 Points
50 Posts
Re: The name xxx Does Not Exist in the Current Context
Dec 01, 2010 08:37 AM|msollicito|LINK
I want to thank you for the tip about having used the same .cs file as somewhere else in the file - cos that fixed my issue related to this!!
None
0 Points
1 Post
Re: The name xxx Does Not Exist in the Current Context
Dec 13, 2010 11:59 AM|cbruen1|LINK
Another cause of this is if you copy and paste code from an aspx page into another aspx page, the designer isn't aware of any new controls that have been pasted, even though they are seen by Intellisense - seems to be a bug to me. The soultion is to create your control(s) in the aspx design screen and name them the same as any code you are pastting in, then paste in the code. This way the designer is aware of the control(s) and the code for them gets generated correctly in the designer.cs file.
None
0 Points
1 Post
Re: The name xxx Does Not Exist in the Current Context
May 11, 2011 04:54 AM|yarakiran|LINK
Thanks man
None
0 Points
6 Posts
Re: The name xxx Does Not Exist in the Current Context
Jun 23, 2011 09:46 AM|dev1dev1|LINK
@psathodten Thanks for posting this. Solved my problem.
None
0 Points
6 Posts
Re: The name xxx Does Not Exist in the Current Context
Jun 23, 2011 09:46 AM|dev1dev1|LINK
@psathodten Thanks for posting this. Solved my problem.
Member
11 Points
96 Posts
Re: The name xxx Does Not Exist in the Current Context
Jul 06, 2011 01:19 PM|jleviaguirre|LINK
this solved my problem. I had a file-old.aspx which was referencing file.aspx.cs causing trouble. I did a search to the entire solution and the culprit was found. I exclude the file instead of renaming it.
The name xxx Does Not Exist in the Current Context