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

  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
    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]" <> 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
    #2
    1. Advertising

  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
    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! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], Dec 3, 2004
    #3
  4. Jiri Zidek

    Jiri Zidek Guest

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

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

    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.)
     
    Steven Cheng[MSFT], Dec 6, 2004
    #5
    1. Advertising

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
    Replies:
    1
    Views:
    406
    dave wanta
    Jun 29, 2003
  2. huobazi
    Replies:
    1
    Views:
    743
    David Waz...
    Jul 3, 2003
  3. Replies:
    0
    Views:
    513
  4. Replies:
    3
    Views:
    3,812
    Arthur
    Jun 23, 2008
  5. Replies:
    2
    Views:
    565
Loading...

Share This Page