When base class is used for UserControl, VS designer fails to load ASCX file

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default When base class is used for UserControl, VS designer fails to load ASCX file

    The problem is that I cannot use VS graphical designer to design my ASCX
    controls that do not inherit directly from System.Web.UI.UserControl but
    they inherit from my base class (which is in fact derived from
    System.Web.UI.UserControl).

    The VS gives me error:
    "The file could not be loaded into the Web FOrms designer. Please correct
    the foloowing error and then try loading it again:
    The designer could not e shown for this file because none of the classes
    within it can be designed. The designer inspected the following classes in
    the file:
    WebUserControl1 -- The ase class 'WebApplication1.BaseWebUSerControl' could
    not be loaded. Ensure the assembly has been referenced or built if it is
    part of the project. Make sure all of the classes used in the page are built
    or referenced in the project."

    Important point: compiling project is OK and when running the pages with
    such controls everything wokrs fine.

    What should I make to work it with designer again ? Some attributes ? Some
    interfaces reimplement ?

    Thanks - Jiri

    Detailed description:

    The idea is similar to idea of baseclass for pages described in
    [url]http://www.codeproject.com/aspnet/AspNetInheritance.asp[/url]. I need to use some
    common functionality for set of web UserControls, I decided to use a common
    baseclass that inherits form System.Web.UI.UserControl:

    public abstract class BaseWebUserControl : System.Web.UI.UserControl {
    ......
    }

    The ASCX file of this base class is almost empty:

    <%@ Control Language="c#" AutoEventWireup="false"
    Codebehind="BaseWebUserControl.ascx.cs"
    Inherits="WebApplication1.BaseWebUserControl"
    TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>

    Then I construct my derived ASCX control with code behind:
    public class WebUserControl1 : BaseWebUserControl {
    ......
    }

    The ASCX file of this derived control is simple:

    <%@ Control Language="c#" AutoEventWireup="false"
    Codebehind="WebUserControl1.ascx.cs"
    Inherits="WebApplication1.WebUserControl1"
    TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
    <asp:textbox id="TextBox1" runat="server"></asp:textbox>
    <asp:button id="Button1" runat="server" text="Button"></asp:button>

    The concept works well for runtime, bud VS designer gets confused.
    I use VS2003. No problem to send simple project showingthe effect.


    Jiri Zidek Guest

  2. Similar Questions and Discussions

    1. Base designer class missing in 2.0
      Hi, I cannot find the base ControlDesigner class in 2.0. All of the documentation I have found points to System.Web.UI.Design.ControlDesigner...
    2. MustInherit base class inherited by UserControl
      Following on from this discussion http://www.dotnet247.com/247reference/msgs/29/146830.aspx i'm having the same problem, the classes that i...
    3. Base usercontrol class and wrapping
      I have created a base class that inherits UserControl. The purpose of this class is to implement common functionality for all of my usercontrols...
    4. how to load an ascx file in class.vb ?
      I need to import an *;ascx, as an object, in my class, that is in myclass.vb. How can i do ? i saw the method LoadControl but i can't use it, or...
    5. Designer refuses to load webform when some of base classes was changed
      We have some base classes library which includes also base web form class. In every new project we adding one web form class which inherits from our...
  3. #2

    Default Re: When base class is used for UserControl, VS designer fails to load ASCX file

    Thanks for response. Your clases are almost the same as in my testing
    project. To be sure I have made a test with yours: a) New WebApplication, a)
    copied your files to the aspx/cs directory, c) Include in project. d) Double
    click on DerivedUserControl.ascx in Solution explorer yields the same error
    as described below.
    See Err-1.png on path [url]http://firma.atlantis.cz/msft[/url] . When pressing OK, the
    ASCX file is displayed but only in HTML view, no Design view available - see
    Err-2.png.
    But again: Bulding - OK, running testpage,.aspx - OK. see OK-3.png in the
    URL above.

    Try with your project to do the same (double click DerivedUserControl.ascx,
    which normally opens design view of ascx) - if working for you - then the
    defect is in my VS2003 installation so I will consider reinstallation (and
    please rceive appologise my bothering).

    If anything more needed no problem.

    Regards
    Jiri

    "Steven Cheng[MSFT]" <v-schang@online.microsoft.com> píše v diskusním
    příspěvku news:4pwwMiB2EHA.3388@cpmsftngxa10.phx.gbl...
    > Hi Jiri,
    >
    > Thanks for your posting. From your description, you have some
    > WebUserControls which dervied from a custom Base UserControl Class(
    > derived
    > from the System.Web.UI.UserControl). They works well at runtime, but can't
    > be loaded correctly in the VS.NET's Design-View at design-time, yes? If
    > anything I misunderstood or not complete, please feel free to let me know.
    >
    > I'm not sure on the detailed control content and code behind code logic of
    > your usercontrols, based on my local test, the derivded control is ok to
    > be
    > loaded into Design-View. And I suspect whether there is anything incorrect
    > when the DESIGN-VIEW load the base control class and try to mapping some
    > class members or other things. Also, are the BaseControl and Derived
    > Control classses put in the same location in the project?
    >
    > Anyway, I've attached my test controls and page in this message , you can
    > have a test on your side to see whether t here is anything different. Hope
    > this helps. If there is any new findings, please feel free to post here.
    >
    > Thanks.
    >
    > Regards,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! [url]www.microsoft.com/security[/url]
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)

    Jiri Zidek Guest

  4. #3

    Default Re: When base class is used for UserControl, VS designer fails to load ASCX file

    Hi Jiri,

    Thanks for your response. Yes, I just test follow the exact same steps you
    mentioned, double click the
    "ascx " file to display the Usercontrol in VS.NET's design view and that
    works ok. Also, I just test again on a XP SP2 box (my original test on a
    win2k3 box), both with .net framework1.1 vs.net2003 installed. Not sure
    any
    enviromential specific problems on your box. But I think before you
    considering reinstall, it is recommend that you try testing on some other
    machines on your side to double check this.

    If there is anything else we can help, please feel free to post here.
    Thanks.

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    Steven Cheng[MSFT] Guest

  5. #4

    Default Re: When base class is used for UserControl, VS designer fails to load ASCX file

    Hello,

    Good idea. I have tested this "inheritance" on another machine and designer
    works without the problem. So I conclude - the defect is in my own VS
    installation. Sorry for bothering.

    Jiri


    Jiri Zidek Guest

  6. #5

    Default Re: When base class is used for UserControl, VS designer fails to load ASCX file

    Thanks for your followup Jiri,

    You're always welcome to post here.
    Good luck!

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    Steven Cheng[MSFT] Guest

  7. #6

    Default Re: When base class is used for UserControl, VS designer fails to load ASCX file

    Hello,

    If anybody has encountered this kind of problem:
    Why: because I am using roaming profile (i.e. my Documents, Desktop and Data
    Application folders are on netowork!), VS stores "some" information in these
    locations, which do not have FullTrust by default (in spite of the fact that
    all my "dev" files are locally on "C:"
    What to do: set FullTrust for the "Local intranet" code group (using Wizard)

    See also: [url]http://www.ai.uga.edu/mc/VisualStudioGotchas.html[/url]
    Or:
    [url]http://www.error-bank.com/microsoft.public.dotnet.framework.aspnet.webcontro ls/15635_Thread.aspx[/url]

    Jiri

    "Jiri Zidek" <Pazu@community.nospam> píše v diskusním příspěvku news:...
    > Hello,
    >
    > Good idea. I have tested this "inheritance" on another machine and
    > designer works without the problem. So I conclude - the defect is in my
    > own VS installation. Sorry for bothering.
    >
    > Jiri
    >

    Jiri Zidek Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139