locked
Custom control only working in app_code folder RRS feed

  • Question

  • User-985212943 posted

    I'm trying to extend the HtmlEditor control to limit the items on the toolbar.  Very simple, works fine, but it only works when I put the class file in the app_code colder of my web project.  This would be fine, but Intellisence does not work in the App_code folder which makes it next to imposible to modify.  Because of the Intellisence issue, I have all my class files in the root folder.  If I put the customEditor class I created in the root, the server tag isn't recognized and I get an error.  Why does the custom control only work in the app_code and secondly, why does Intellisence not work in the app_code directory?

    My Customcontrol code:

    namespace BCN.CustomControls
    {
        public class CustomEditor : Editor
        {
            protected override void FillTopToolbar()
            {
                TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.Undo());
                TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.Redo());
                TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.Bold());
     ......
    
            }
        }
    }
    

    My page code:

    <%@ Register namespace="BCN.CustomControls" tagprefix="custom" %>
    
    <custom:CustomEditor  Width="400px" Height="200px" runat="server" />


    My Error:

    Parser Error Message: Unknown server tag 'custom:CustomEditor'.
    
    Source Error:
    
    Line 89:         <div style="width: 580px; margin-left: 375px;border:solid 1px black;">
    Line 90:             <cc1:Editor ID="Editor1" runat="server"  />
    Line 91:           <custom:CustomEditor  Width="400px" Height="200px" runat="server" />
    Line 92:   
    Line 93:         </div>


    Saturday, August 1, 2009 6:16 PM

Answers

  • User-2106054853 posted

     I believe the example you're following is for Web Site. In Web Application project we don't have to put class.cs under App_Code folder. If you have to do so and need Intellisence, please click the file, view the properties window and check the "Build Action" of this file. By default it's "Content". Please change it to "Compile".

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 4, 2009 3:30 AM

All replies

  • User-2106054853 posted

     Hi,

    Why does the custom control only work in the app_code and secondly, why does Intellisence not work in the app_code directory?

    If you're writing Web Site project you have to put your code in App_Code. I'm not sure why Intellisence is not working. Could you try the following way to see if it can be fixed?

    http://msdn.microsoft.com/en-us/library/ms241273(VS.80).aspx

    Monday, August 3, 2009 3:09 AM
  • User-985212943 posted

    It's a Web Application Project.  You don't get an App_Code folder by default.  I followed an example stating that you needed to place the custom control in the App_Code folder and it worked but no Intellisence.  If I move the control out of the App_code folder, Intellisence works but the control isn't recognized.  There has to be a solution for this.

    Monday, August 3, 2009 10:53 AM
  • User-2106054853 posted

     I believe the example you're following is for Web Site. In Web Application project we don't have to put class.cs under App_Code folder. If you have to do so and need Intellisence, please click the file, view the properties window and check the "Build Action" of this file. By default it's "Content". Please change it to "Compile".

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 4, 2009 3:30 AM