Control does not exist in the current context error in VS 2008

Last post 06-02-2011, 1:36 PM by Eric. 8 replies.
Sort Posts: Previous Next
  •  05-02-2009, 9:10 PM 51767

    Control does not exist in the current context error in VS 2008

    I am testing out the free download and have not yet purchased a license.  Not sure if that effects what I am doing.
     
    I have included the Editor in my page and it shows up fine when I run the page.  But when I try to access the control in my code-behind file I get an error saying "The name 'Editor1' does not exist in the current context."
     
    I also noticed that there is no Intellisense in the code behind but in the ASPX file the Intellisense is there for the various options in the tag.  It seems that the Editor control is not being included in the aspx.designer.cs file which could be causing it.
     
    How can I get this to work.  I am using Visual Studio 2008 on a Vista computer.
     
    Also, once I get it working, I'm assuming that the Text property is what I will use to get the HTML that was created?
     
    Thanks,
     
    Jeff
  •  05-04-2009, 8:39 AM 51780 in reply to 51767

    Re: Control does not exist in the current context error in VS 2008

    Hi jtreuting,
     
    Can you post you code here?
     
    Regards,
     
    Ken
     
     
  •  05-05-2009, 8:38 PM 51853 in reply to 51780

    Re: Control does not exist in the current context error in VS 2008

    ASPX PAGE
    -----------------------------------------
     
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestEditor.aspx.cs" Inherits="CMS.TestEditor" %>
    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
            <CE:Editor ID="cuteEditor" runat="server" Autoconfigure="Simple" />  
        
            <br />
            <asp:Button ID="submitButton" runat="server" Text="Save" OnClick="submitButton_Click" />
            
            <hr />
            
            <asp:Literal ID="htmlText" runat="server" />
        </div>
        </form>
    </body>
    </html>
     
    -------------------------------
    CODE BEHIND
    -------------------------------
    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;

    namespace CMS
    {
        public partial class TestEditor : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {

            }

            protected void submitButton_Click(object sender, EventArgs e)
            {
                htmlText.Text = cuteEditor.Text;
            }
        }
    }
     
     -----------------------
     DESIGNER FILE
    --------------------------
    namespace CMS {
       
        public partial class TestEditor {
            
            /// <summary>
            /// form1 control.
            /// </summary>
            /// <remarks>
            /// Auto-generated field.
            /// To modify move field declaration from designer file to code-behind file.
            /// </remarks>
            protected global::System.Web.UI.HtmlControls.HtmlForm form1;
        }
    }
     
    ----------------------------
     
    So as you can see the controls aren't getting added to the designer file so it doesn't know about the controls in the code behind file.
     
    This is the error that I am getting when I try to run the page.
     
    Error    4    The name 'htmlText' does not exist in the current context    C:\Projects\CMS\CMS\TestEditor.aspx.cs    25    13    CMS
    Error    5    The name 'cuteEditor' does not exist in the current context    C:\Projects\CMS\CMS\TestEditor.aspx.cs    25    29    CMS
     
    If I get rid of the Editor control then it runs and the designer file has the appropriate controls in it.
     
     
    Thanks,
     
    Jeff
  •  05-05-2009, 10:21 PM 51855 in reply to 51853

    Re: Control does not exist in the current context error in VS 2008

    Hi Jeff,
     
    If you use Cute Editor in a web application, Please add reference for CuteEditor.dll
     
     
     
     
    Regards,
     
    ken
  •  05-05-2009, 10:39 PM 51856 in reply to 51855

    Re: Control does not exist in the current context error in VS 2008

    That was it.  I had the DLL's in the bin but forgot to add the reference.
     
    Thanks!
  •  05-24-2011, 5:18 PM 67676 in reply to 51855

    Re: Control does not exist in the current context error in VS 2008

    Hello,
     
    I keep getting this error at line 26 even though I have added a reference for my CuteEditor.dll. Please help.
     
    Thanks
    Mel
     

    Compilation Error

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: CS0103: The name 'CuteEditor' does not exist in the current context

    Source Error:


    Line 24: 		<meta name="GENERATOR" content="CuteEditor">
    Line 25: <base target="_blank" href="<%=Server.HtmlEncode(referrer)%>" />
    Line 26: <link type="text/css" rel="stylesheet" href='<%=CuteEditor.EditorUtility.ProcessWebPath(Context,Page,"Load.ashx?type=style&file=SyntaxHighlighter.css")%>' />
    Line 27: </head>
    Line 28: <body>

    Source File: c:\Inetpub\wwwroot\PRISM\u\formulator\CuteSoft_Client\CuteEditor\Template.aspx    Line: 26


    Show Detailed Compiler Output:

    Show Complete Compilation Source:
     
  •  05-25-2011, 9:53 AM 67679 in reply to 51767

    Re: Control does not exist in the current context error in VS 2008

    Dear jtreuting,
     
    Did you "Add Reference" to CuteEditor.dll? 
    Please save the following example to test.aspx, and then run this example, can you reproduce this issue?
     
    <%@ Page Language="C#"%>
    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
        <head>
      <title>ASP and ASP.NET WYSIWYG Editor - Edit Static Html Example </title> 
     </head>
     <body>
            <form id="Form1" runat="server">   
            <CE:Editor id="Editor1" runat="server" ></CE:Editor><BR>
            <asp:Button id="btnUpdate" onclick="Submit" Runat="server" Text="Submit"></asp:Button><br />   
         <asp:textbox id="textbox1" runat="server" TextMode="MultiLine" Height="250px" Width="750px" Font-Name="Arial"></asp:TextBox> 
      </form>
     </body>
    </html>
    <script runat="server">
     void Page_Load(object sender, System.EventArgs e)
     {       
     }
     public void Submit(object sender, System.EventArgs e)
     {   
       textbox1.Text = Editor1.PlainText; 
     }
    </script>
     
    Thanks for asking
  •  06-02-2011, 11:21 AM 67781 in reply to 67679

    Re: Control does not exist in the current context error in VS 2008

    Hello,
     
    I have already added a reference. If I create a separate test page, I get a blank screen. If I use it within my code, I get the context error. I am using VS 2005, are the settings different for VS 2005?
     
    Please help, I have been struggling with this for a week now.
     
    Thanks
    Melrine
     
     
     
  •  06-02-2011, 1:36 PM 67783 in reply to 67781

    Re: Control does not exist in the current context error in VS 2008

    Dear Melrine,
     
    Please come to LiveSupport at http://CuteSoft.net , click on the big blue button on top that reads "online". We are here Monday - Friday between 9:30am and 17:30pm Eastern Standard Time.

    I will provide gotomeeting link to you, you can share your desktop to us, we will check it for you.
     
    Thanks for asking
View as RSS news feed in XML