The name xxx Does Not Exist in the Current Context

Last post 10-29-2009 12:15 PM by sumanabk. 42 replies.

Sort Posts:

  • The name xxx Does Not Exist in the Current Context

    07-09-2006, 4:49 PM
    • Member
      30 point Member
    • Tepi
    • Member since 07-09-2006, 8:26 PM
    • Posts 4

    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?

  • Re: The name xxx Does Not Exist in the Current Context

    07-10-2006, 1:57 PM
    How exactly code behind file and the page markup look like? Are you placing assignment in the Page_Load?
    Thanks

    ------------------------------------------------------------

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: The name xxx Does Not Exist in the Current Context

    07-10-2006, 8:28 PM
    • Member
      30 point Member
    • Tepi
    • Member since 07-09-2006, 8:26 PM
    • Posts 4
    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;

    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" />&nbsp;
        <asp:RegularExpressionValidator
                    ID="sessNumValidator" runat="server" ControlToValidate="TextBox1" ErrorMessage="Session number must be one to 6 numeric digits"
                    ValidationExpression="\d{1,6}"></asp:RegularExpressionValidator>&nbsp;
        <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>




  • Re: The name xxx Does Not Exist in the Current Context

    07-13-2006, 11:17 PM
    • Member
      30 point Member
    • Tepi
    • Member since 07-09-2006, 8:26 PM
    • Posts 4
    New but equally baffling information:

    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.
  • Re: The name xxx Does Not Exist in the Current Context

    07-21-2006, 7:16 PM
    Answer
    • Member
      30 point Member
    • Tepi
    • Member since 07-09-2006, 8:26 PM
    • Posts 4
    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.

    Keith

  • Re: The name xxx Does Not Exist in the Current Context

    09-14-2006, 11:27 PM
    • Member
      715 point Member
    • justinsaraceno
    • Member since 03-30-2003, 12:11 PM
    • Raleigh, NC
    • Posts 156
    wow - this helped a lot!  I was having the same problem.  Thanks!
  • Re: The name xxx Does Not Exist in the Current Context

    05-17-2007, 9:34 AM
    • Member
      2 point Member
    • digi dave
    • Member since 05-17-2007, 1:33 PM
    • Posts 1

    cheers Tepi for posting the fix - just had a very confusing 30 minutes with the same prob - turning build off sorted it.....

  • Re: The name xxx Does Not Exist in the Current Context

    06-01-2007, 8:26 PM

    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!

  • Re: The name xxx Does Not Exist in the Current Context

    06-11-2007, 7:26 PM
    • Member
      2 point Member
    • psatodten
    • Member since 06-11-2007, 11:13 PM
    • Posts 1

    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...

  • Re: The name xxx Does Not Exist in the Current Context

    07-09-2007, 8:11 AM
    • Member
      2 point Member
    • jjstewar
    • Member since 07-09-2007, 12:08 PM
    • Posts 1

     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.

  • Re: The name xxx Does Not Exist in the Current Context

    07-20-2007, 12:28 PM
    • Member
      4 point Member
    • Ken_Walsh
    • Member since 07-20-2007, 4:21 PM
    • Posts 2

    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?

     


     
     

     

  • Re: The name xxx Does Not Exist in the Current Context

    07-20-2007, 1:33 PM
    • Member
      4 point Member
    • Ken_Walsh
    • Member since 07-20-2007, 4:21 PM
    • Posts 2

     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

     

  • Re: The name xxx Does Not Exist in the Current Context

    08-13-2007, 12:50 PM
    Answer
    • Member
      24 point Member
    • devThis
    • Member since 09-06-2006, 7:58 PM
    • Posts 5

    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.

  • Re: The name xxx Does Not Exist in the Current Context

    09-21-2007, 11:35 AM
    • Member
      22 point Member
    • Gewgala
    • Member since 07-26-2007, 9:18 PM
    • Posts 71

    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!!

  • Re: The name xxx Does Not Exist in the Current Context

    04-18-2008, 3:29 PM
    • Member
      10 point Member
    • bradwoody
    • Member since 08-24-2007, 7:59 PM
    • Prestbury, IL
    • Posts 18

    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

Page 1 of 3 (43 items) 1 2 3 Next >