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

Discussion in 'ASP .Net Building Controls' started by Jiri Zidek, Dec 1, 2004.

  1. Jiri Zidek

    Jiri Zidek Guest

    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

    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
    http://www.codeproject.com/aspnet/AspNetInheritance.asp. 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"

    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"
    <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, Dec 1, 2004
    1. Advertisements

  2. Jiri Zidek

    Jiri Zidek Guest

    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 http://firma.atlantis.cz/msft . When pressing OK, the
    ASCX file is displayed but only in HTML view, no Design view available - see
    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.


    "Steven Cheng[MSFT]" <> pí¹e v diskusním
    pøíspìvku news:...
    > 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! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    Jiri Zidek, Dec 2, 2004
    1. Advertisements

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


    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    Steven Cheng[MSFT], Dec 3, 2004
  4. Jiri Zidek

    Jiri Zidek Guest


    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 Zidek, Dec 3, 2004
  5. Thanks for your followup Jiri,

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


    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    Steven Cheng[MSFT], Dec 6, 2004
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anatoly
    dave wanta
    Jun 29, 2003
  2. huobazi
    David Waz...
    Jul 3, 2003
  3. Quentin
    Ryan Gregg
    Jul 30, 2003
  4. Replies:
  5. Alf P. Steinbach
    John Carson
    Sep 3, 2005
  6. Replies:
    Jun 23, 2008
  7. Hicham Mouline
    Victor Bazarov
    Apr 20, 2009
  8. Replies: