User Control not rendered in Visual Studio

Discussion in 'ASP .Net Building Controls' started by Brendon, Mar 23, 2005.

  1. Brendon

    Brendon Guest

    I have created a custom composite server control. When I drag the control
    from the toolbox into Visual Studio it does not display in Visual Studio,
    instead it shows the littel green arrow and nothing else. When I run the
    application it shows the LiteralControl that I have added. Does anyone know
    what I might be missing to make it also show up in Visual Studio? I have
    included the entire class that I am trying to make.

    Thanks,
    Brendon

    [ToolboxData("<{0}:NextEvent runat=server></{0}:NextEvent>")]
    public class NextEvent :
    System.Web.UI.WebControls.WebControl,INamingContainer
    {
    protected override void CreateChildControls()
    {
    Controls.Add(new LiteralControl("<h3>Enter a number : </h3>"));

    }

    }
     
    Brendon, Mar 23, 2005
    #1
    1. Advertising

  2. Jason Bentley, Mar 23, 2005
    #2
    1. Advertising

  3. Brendon

    Brendon Guest

    From what I have read you don't need to implement the OnPreRender or Render
    if you are creating a composite web control. The function
    CreateChildControls() will write all of the Rendering for you. I believe
    that is why you are suppose to call EnsureChildControls(), but I do not have
    any properties so I am not call that function. I was wondering if there was
    a way to do a Composite control without the OnPreRender or Render methods.

    Thanks and please let me know if you have any more ideas.
    Brendon

    "Jason Bentley" wrote:

    > Brendon, you are not using OnPreRender or Render in your control. You
    > won't see any output unless you do.
    >
    > Jason Bentley
    > http://geekswithblogs.net/jbentley
    >
    >
     
    Brendon, Mar 23, 2005
    #3
  4. Brendon, you are right; you do not have to use OnRender or Render. If
    you want to see a visual representation of your control at design time
    support and do not override the Render events you will have to
    implement a designer class via System.Web.UI.Design.ControlDesigner.
    Sorry. Here is a brief discussion on the topic:
    http://www.mcse.ms/message1479961.html

    Jason Bentley
    http://geekswithblogs.net/jbentley
     
    Jason Bentley, Mar 24, 2005
    #4
  5. Brendon

    Brendon Guest

    Thank you for all of the help, I will look into a custom designer for my
    control. The problem that I still see is I have a class that doesn't
    implement OnRender or Render and doesn't have it's own custom designer, but
    still renders in both the designer and on a web page. I will keep working
    at, but thanks for the input so far Jason.

    "Jason Bentley" wrote:

    > Brendon, you are right; you do not have to use OnRender or Render. If
    > you want to see a visual representation of your control at design time
    > support and do not override the Render events you will have to
    > implement a designer class via System.Web.UI.Design.ControlDesigner.
    > Sorry. Here is a brief discussion on the topic:
    > http://www.mcse.ms/message1479961.html
    >
    > Jason Bentley
    > http://geekswithblogs.net/jbentley
    >
    >
     
    Brendon, Mar 24, 2005
    #5
  6. Brendon

    Guest

    If you are implementing your own designer and the control renders at
    runtime then it very well could be that the CreateChildControls is not
    getting called at design time.

    Either way I would check to see if CreateControl is getting called at
    design time.
     
    , Mar 29, 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. wh
    Replies:
    2
    Views:
    531
    Cowboy \(Gregory A. Beamer\)
    Jan 16, 2004
  2. Leeor Chernov
    Replies:
    2
    Views:
    793
    Leeor Chernov
    Oct 16, 2005
  3. Thirumalai
    Replies:
    0
    Views:
    674
    Thirumalai
    May 22, 2006
  4. rockdale
    Replies:
    1
    Views:
    621
    Juan T. Llibre
    Aug 23, 2006
  5. xman
    Replies:
    0
    Views:
    513
Loading...

Share This Page