User Control not rendered in Visual Studio

B

Brendon

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>"));

}

}
 
B

Brendon

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
 
B

Brendon

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

recoil

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top