asp.net custom server control not showing when dragged onto web fo

Discussion in 'ASP .Net Web Controls' started by SpencerW, May 24, 2005.

  1. SpencerW

    SpencerW Guest

    I've created a custom composite calendar server control in asp.net. I've
    compiled the dll and added it to my toolbox, but when I drag and drop it onto
    a web form, I don't see the control in the designer. All I can see is a tiny
    little green arrow. It shows up in the property explorer for the page and
    the control works just fine when the page is rendered on a browser. The
    problem is that I don't see it on the form in the vs.net web form designer
    and that is perplexing. Anyone have any ideas on why this is happening and
    what I can do to fix it?
    SpencerW, May 24, 2005
    #1
    1. Advertising

  2. Hi Spencer,

    Welcome to ASPNET newsgroup.
    From your description, you're developing a custom webserver control
    (composite control) which will contain a Calendar inside it. However when
    you draged the control on a webform page at design-time you found it
    displayed nothing on the webform's design-view, yes?

    Based on my understanding, what you have encountered was the expected
    behavior. This is because by default, VS.NET will call the Control's Render
    method get the html displayed in design-view. And for Composite control, we
    used CreateChildControls to construct the control hierarchy rather than
    using Render method , so you'll get the empty(an arrow only) in
    design-view.

    If we do need to provide our customized Html View for our control at
    design-view, we can consider creating a custom control designer for our
    composite control. For example:

    we can apply a custom ControlDesigner class for a custom control like:

    [ Designer("CustomControls.Design.SimpleDesigner, CustomControls.Design")]
    public class Simple : WebControl {
    ....................
    }

    And we can override the "GetDesignTimeHtml() " method of the
    ControlDesigner class which is used to return the html code to display in
    IDE at design-time. For detailed description, you can refer to the
    following MSDN document:

    #Implementing a Simple Web Forms Control Designer
    http://msdn.microsoft.com/library/en-us/cpguide/html/cpconhtmldesignersample
    ..asp?frame=true

    Hope helps. Thanks,

    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], May 25, 2005
    #2
    1. Advertising

  3. SpencerW

    SpencerW Guest

    RE: asp.net custom server control not showing when dragged onto we

    Steve,
    Thanks for the reply, you are correct in your diagnosis of the problem. The
    code in the article you provided a link to seems as though it should work.
    One problem with it though - I cannot import System.Web.UI.Design or inherit
    from System.Web.UI.Design.ControlDesigner. Also, I'm not sure what the
    CustomControls library is that is imported in the example, but I cannot
    import that either. Am I missing a reference or a file or something? Please
    let me know the answer to this question and it should answer my initial one.
    Thanks.

    Spencer


    "Steven Cheng[MSFT]" wrote:

    > Hi Spencer,
    >
    > Welcome to ASPNET newsgroup.
    > From your description, you're developing a custom webserver control
    > (composite control) which will contain a Calendar inside it. However when
    > you draged the control on a webform page at design-time you found it
    > displayed nothing on the webform's design-view, yes?
    >
    > Based on my understanding, what you have encountered was the expected
    > behavior. This is because by default, VS.NET will call the Control's Render
    > method get the html displayed in design-view. And for Composite control, we
    > used CreateChildControls to construct the control hierarchy rather than
    > using Render method , so you'll get the empty(an arrow only) in
    > design-view.
    >
    > If we do need to provide our customized Html View for our control at
    > design-view, we can consider creating a custom control designer for our
    > composite control. For example:
    >
    > we can apply a custom ControlDesigner class for a custom control like:
    >
    > [ Designer("CustomControls.Design.SimpleDesigner, CustomControls.Design")]
    > public class Simple : WebControl {
    > ....................
    > }
    >
    > And we can override the "GetDesignTimeHtml() " method of the
    > ControlDesigner class which is used to return the html code to display in
    > IDE at design-time. For detailed description, you can refer to the
    > following MSDN document:
    >
    > #Implementing a Simple Web Forms Control Designer
    > http://msdn.microsoft.com/library/en-us/cpguide/html/cpconhtmldesignersample
    > .asp?frame=true
    >
    > Hope helps. Thanks,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    >
    SpencerW, May 25, 2005
    #3
  4. RE: asp.net custom server control not showing when dragged onto we

    Hi Spencer,

    The "CustomControls.Design" in the example is just a test namespace, we
    don't need to care about it. And the ControlDesigner class is under the
    System.Web.UI.Design namespace. However, the System.Web.UI.Design
    namespace are not in the same assembly with the System.Web.UI namespace.
    We need to add reference of the

    System.Design.dll (contains the System.Web.UI.Design namespace) first.

    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], May 26, 2005
    #4
  5. SpencerW

    SpencerW Guest

    RE: asp.net custom server control not showing when dragged onto we

    Yup, that did it. Too bad the ms article didn't mention that. Thanks for
    the help.

    "SpencerW" wrote:

    > Steve,
    > Thanks for the reply, you are correct in your diagnosis of the problem. The
    > code in the article you provided a link to seems as though it should work.
    > One problem with it though - I cannot import System.Web.UI.Design or inherit
    > from System.Web.UI.Design.ControlDesigner. Also, I'm not sure what the
    > CustomControls library is that is imported in the example, but I cannot
    > import that either. Am I missing a reference or a file or something? Please
    > let me know the answer to this question and it should answer my initial one.
    > Thanks.
    >
    > Spencer
    >
    >
    > "Steven Cheng[MSFT]" wrote:
    >
    > > Hi Spencer,
    > >
    > > Welcome to ASPNET newsgroup.
    > > From your description, you're developing a custom webserver control
    > > (composite control) which will contain a Calendar inside it. However when
    > > you draged the control on a webform page at design-time you found it
    > > displayed nothing on the webform's design-view, yes?
    > >
    > > Based on my understanding, what you have encountered was the expected
    > > behavior. This is because by default, VS.NET will call the Control's Render
    > > method get the html displayed in design-view. And for Composite control, we
    > > used CreateChildControls to construct the control hierarchy rather than
    > > using Render method , so you'll get the empty(an arrow only) in
    > > design-view.
    > >
    > > If we do need to provide our customized Html View for our control at
    > > design-view, we can consider creating a custom control designer for our
    > > composite control. For example:
    > >
    > > we can apply a custom ControlDesigner class for a custom control like:
    > >
    > > [ Designer("CustomControls.Design.SimpleDesigner, CustomControls.Design")]
    > > public class Simple : WebControl {
    > > ....................
    > > }
    > >
    > > And we can override the "GetDesignTimeHtml() " method of the
    > > ControlDesigner class which is used to return the html code to display in
    > > IDE at design-time. For detailed description, you can refer to the
    > > following MSDN document:
    > >
    > > #Implementing a Simple Web Forms Control Designer
    > > http://msdn.microsoft.com/library/en-us/cpguide/html/cpconhtmldesignersample
    > > .asp?frame=true
    > >
    > > Hope helps. Thanks,
    > >
    > > Steven Cheng
    > > Microsoft Online Support
    > >
    > > Get Secure! www.microsoft.com/security
    > > (This posting is provided "AS IS", with no warranties, and confers no
    > > rights.)
    > >
    > >
    SpencerW, May 26, 2005
    #5
  6. RE: asp.net custom server control not showing when dragged onto we

    You're welcome Spencer,

    Thanks again for using MSDN newsgroup.

    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], May 27, 2005
    #6
    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. Dave
    Replies:
    0
    Views:
    460
  2. Mathematician
    Replies:
    0
    Views:
    550
    Mathematician
    Dec 24, 2006
  3. Brian Edwards

    Can't drag Web Custom Control from Toolbox onto Webform

    Brian Edwards, Nov 14, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    165
    Brian Edwards
    Nov 14, 2005
  4. Andy

    change properties of dragged object

    Andy, Sep 8, 2004, in forum: Javascript
    Replies:
    1
    Views:
    97
    Martin Honnen
    Sep 8, 2004
  5. Replies:
    1
    Views:
    126
    Joshie Surber
    Nov 19, 2005
Loading...

Share This Page