Design-time rendering of User Control

Discussion in 'ASP .Net Building Controls' started by PV, Oct 29, 2003.

  1. PV

    PV Guest

    Like many others, I would like to replace the default "grey button" display
    of my user control with something that more closely (better yet exactly)
    resembles the runtime display of the control.

    In an attempt to do just this, I created my own designer class for my
    "Header" user control. For now, the designer just returns "<h1>Page
    Header</h1" from the GetDesignTimeHtml() method. Then I added the Designer
    attribute to the class definition for my Header user control's code-behind.
    There is no effect in the designer.

    I did a google search on this group, and have found suggestions, but not a
    confirmation that it is not possible to specify a designer for a user
    control. Can anybody confirm this for me? I don't see why it shouldn't
    work. Other than a "code in-front" page, what is the difference between a
    user control and a server control? They are just classes! Is it just
    laziness on the part of Microsoft? Or is there a real issue here?

    I would just avoid the situation and create a server control instead,
    however the very nature of my Header is such that I would like graphic
    designers to be able to modify it any time they want. Obviously a user
    control is what I need.

    I considered just wrapping my user control with a server control, but ...
    yeach. I don't want to go there.

    Suggestions?
     
    PV, Oct 29, 2003
    #1
    1. Advertising

  2. PV

    PV Guest

    Further to this discussion, I discovered a class:
    System.Web.UI.Design.UserControlDesigner

    To test that it is being used by my user control, I removed my custom
    "Designer" attribute, and added the following code to the Page_Load method:

    System.ComponentModel.AttributeCollection attributes =
    TypeDescriptor.GetAttributes(this);

    DesignerAttribute myAttribute =

    (DesignerAttribute)attributes[typeof(DesignerAttribute)];

    this.Label1.Text = myAttribute.DesignerTypeName;

    Label1 did verify (at run time) that the UserControlDesigner is attached. I
    then added back in my custom designer attribute. Label1 verified that my
    new attribute was applied. However, there is no effect on the design-time
    environment. I even put code into the constructor of my designer to throw
    an exception. Still no effect in the design-time environment. It seems my
    custom designer isn't even being constructed!


    "PV" <> wrote in message
    news:...
    > Like many others, I would like to replace the default "grey button"

    display
    > of my user control with something that more closely (better yet exactly)
    > resembles the runtime display of the control.
    >
    > In an attempt to do just this, I created my own designer class for my
    > "Header" user control. For now, the designer just returns "<h1>Page
    > Header</h1" from the GetDesignTimeHtml() method. Then I added the

    Designer
    > attribute to the class definition for my Header user control's

    code-behind.
    > There is no effect in the designer.
    >
    > I did a google search on this group, and have found suggestions, but not a
    > confirmation that it is not possible to specify a designer for a user
    > control. Can anybody confirm this for me? I don't see why it shouldn't
    > work. Other than a "code in-front" page, what is the difference between a
    > user control and a server control? They are just classes! Is it just
    > laziness on the part of Microsoft? Or is there a real issue here?
    >
    > I would just avoid the situation and create a server control instead,
    > however the very nature of my Header is such that I would like graphic
    > designers to be able to modify it any time they want. Obviously a user
    > control is what I need.
    >
    > I considered just wrapping my user control with a server control, but ...
    > yeach. I don't want to go there.
    >
    > Suggestions?
    >
    >
     
    PV, Oct 29, 2003
    #2
    1. Advertising

  3. "PV" <> wrote in message
    news:...
    > Further to this discussion, I discovered a class:
    > System.Web.UI.Design.UserControlDesigner
    >
    > To test that it is being used by my user control, I removed my custom
    > "Designer" attribute, and added the following code to the Page_Load

    method:
    >
    > System.ComponentModel.AttributeCollection attributes =
    > TypeDescriptor.GetAttributes(this);
    >
    > DesignerAttribute myAttribute =
    >
    > (DesignerAttribute)attributes[typeof(DesignerAttribute)];
    >
    > this.Label1.Text = myAttribute.DesignerTypeName;
    >
    > Label1 did verify (at run time) that the UserControlDesigner is attached.

    I
    > then added back in my custom designer attribute. Label1 verified that my
    > new attribute was applied. However, there is no effect on the design-time
    > environment. I even put code into the constructor of my designer to throw
    > an exception. Still no effect in the design-time environment. It seems

    my
    > custom designer isn't even being constructed!


    You are correct. You can't do what you want.
    --
    John
     
    John Saunders, Oct 29, 2003
    #3
  4. PV

    JL Guest


    > You are correct. You can't do what you want.
    > --


    Ok but why? I'm curious..
     
    JL, Oct 30, 2003
    #4
  5. "JL" <> wrote in message
    news:O#nP#...
    >
    > > You are correct. You can't do what you want.
    > > --

    >
    > Ok but why? I'm curious..


    Because Microsoft said so. You'll have to ask them. They'll probably say
    something like "this is a limitation of user controls, which are meant to be
    convenient but not very feature-rich. These limitations can be overcome by
    writing a Web Custom Control".

    It would be nice if one or two of these feature limitations were removed in
    version 2.
    --
    John
     
    John Saunders, Oct 30, 2003
    #5
  6. Are User Control instanciated at design time ? It not it would explain the
    limited desing time support....

    Patrice

    --

    "John Saunders" <john.saunders at surfcontrol.com> a écrit dans le message
    de news:...
    > "JL" <> wrote in message
    > news:O#nP#...
    > >
    > > > You are correct. You can't do what you want.
    > > > --

    > >
    > > Ok but why? I'm curious..

    >
    > Because Microsoft said so. You'll have to ask them. They'll probably say
    > something like "this is a limitation of user controls, which are meant to

    be
    > convenient but not very feature-rich. These limitations can be overcome by
    > writing a Web Custom Control".
    >
    > It would be nice if one or two of these feature limitations were removed

    in
    > version 2.
    > --
    > John
    >
    >
     
    Patrice Scribe, Nov 3, 2003
    #6
  7. I assume that they are - Controls are instantiated and User Controls are
    Controls.

    --
    John


    "Patrice Scribe" <> wrote in message
    news:...
    > Are User Control instanciated at design time ? It not it would explain the
    > limited desing time support....
    >
    > Patrice
    >
    > --
    >
    > "John Saunders" <john.saunders at surfcontrol.com> a écrit dans le message
    > de news:...
    > > "JL" <> wrote in message
    > > news:O#nP#...
    > > >
    > > > > You are correct. You can't do what you want.
    > > > > --
    > > >
    > > > Ok but why? I'm curious..

    > >
    > > Because Microsoft said so. You'll have to ask them. They'll probably

    say
    > > something like "this is a limitation of user controls, which are meant

    to
    > be
    > > convenient but not very feature-rich. These limitations can be overcome

    by
    > > writing a Web Custom Control".
    > >
    > > It would be nice if one or two of these feature limitations were removed

    > in
    > > version 2.
    > > --
    > > John
    > >
    > >

    >
     
    John Saunders, Nov 4, 2003
    #7
  8. PV

    Teemu Keiski Guest

    Limited design-time support is just a design decision MS made with v.1. In
    becoming releases one can expect to see good design-time support for user
    controls as well (as is already with current version of Web Matrix).

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist

    "Patrice Scribe" <> wrote in message
    news:...
    > Are User Control instanciated at design time ? It not it would explain the
    > limited desing time support....
    >
    > Patrice
    >
    > --
    >
    > "John Saunders" <john.saunders at surfcontrol.com> a écrit dans le message
    > de news:...
    > > "JL" <> wrote in message
    > > news:O#nP#...
    > > >
    > > > > You are correct. You can't do what you want.
    > > > > --
    > > >
    > > > Ok but why? I'm curious..

    > >
    > > Because Microsoft said so. You'll have to ask them. They'll probably

    say
    > > something like "this is a limitation of user controls, which are meant

    to
    > be
    > > convenient but not very feature-rich. These limitations can be overcome

    by
    > > writing a Web Custom Control".
    > >
    > > It would be nice if one or two of these feature limitations were removed

    > in
    > > version 2.
    > > --
    > > John
    > >
    > >

    >
     
    Teemu Keiski, Nov 6, 2003
    #8
    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. Barry Carr
    Replies:
    4
    Views:
    798
    Barry Carr
    Jan 15, 2004
  2. Stephen Miller
    Replies:
    1
    Views:
    288
    Alessandro Zifiglio
    Jan 2, 2004
  3. Sam Fields

    Rendering DataGrid in a custom control at design time

    Sam Fields, Jan 15, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    152
    Sam Fields
    Jan 15, 2004
  4. Joey Lee

    Rendering Custom Control during design time

    Joey Lee, Jun 30, 2005, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    155
    Joey Lee
    Jul 1, 2005
  5. Bill Cohagan

    Design Time Rendering User Control?

    Bill Cohagan, Jul 21, 2006, in forum: ASP .Net Building Controls
    Replies:
    17
    Views:
    581
    Walter Wang [MSFT]
    Aug 9, 2006
Loading...

Share This Page