Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > CreateChildControl vs RenderContents

Reply
Thread Tools

CreateChildControl vs RenderContents

 
 
Paul S
Guest
Posts: n/a
 
      02-22-2010
I'm creating a Custom Server Control
public class DataFormControl : CompositeControl, INamingContainer

The controls are added dynamically depending on the values set on the
properties.

Do I need to go through my logic to determine what controls to add twice -
first when I create the controls in CreateChildControls and the in
RenderContent to render the controls?

or am I just of track here?.

I would appreciate some clarification

Thanks
Paul S

 
Reply With Quote
 
 
 
 
Hemant
Guest
Posts: n/a
 
      02-23-2010
You can either use CreateChildControls or Rendercontaint.
if you want to use child controls you can use createchild controls(other
controls like textbox etc) or you want to dynamically output html then use
rendercontaint.

Hemant

"Paul S" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm creating a Custom Server Control
> public class DataFormControl : CompositeControl, INamingContainer
>
> The controls are added dynamically depending on the values set on the
> properties.
>
> Do I need to go through my logic to determine what controls to add twice -
> first when I create the controls in CreateChildControls and the in
> RenderContent to render the controls?
>
> or am I just of track here?.
>
> I would appreciate some clarification
>
> Thanks
> Paul S
>

 
Reply With Quote
 
 
 
 
Paul S
Guest
Posts: n/a
 
      02-23-2010

If I do this nothing gets rendered - what do I need to do also?

PlaceHolder ph;
protected override void CreateChildControls()
{
base.CreateChildControls();
this.ph = new PlaceHolder();

TextBox tb = new TextBox();
tb.Text = this.Text;
Button bt = new Button();
bt.Text = "Click";


ph.Controls.Add(tb);
ph.Controls.Add(bt);

this.Controls.Add(ph);
}
protected override void RenderContents(HtmlTextWriter writer)
{
ph.RenderControl(writer);
}

"Hemant" wrote:

> You can either use CreateChildControls or Rendercontaint.
> if you want to use child controls you can use createchild controls(other
> controls like textbox etc) or you want to dynamically output html then use
> rendercontaint.
>
> Hemant
>
> "Paul S" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I'm creating a Custom Server Control
> > public class DataFormControl : CompositeControl, INamingContainer
> >
> > The controls are added dynamically depending on the values set on the
> > properties.
> >
> > Do I need to go through my logic to determine what controls to add twice -
> > first when I create the controls in CreateChildControls and the in
> > RenderContent to render the controls?
> >
> > or am I just of track here?.
> >
> > I would appreciate some clarification
> >
> > Thanks
> > Paul S
> >

> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Render vs RenderContents Alex Nitulescu ASP .Net 2 08-17-2009 08:46 AM
Inheriting System.Web.UI.WebControls.Image and RenderContents Nathan Sokalski ASP .Net 1 07-31-2009 04:44 AM
RenderContents not rendering programmatically set attributes inherited from System.Web.UI.WebControls.Image Nathan Sokalski ASP .Net 1 07-31-2009 04:44 AM
CreateChildControl() fires First hsnkamal@yahoo.com ASP .Net Building Controls 1 06-25-2007 08:24 AM
RenderContents Doug Holland ASP .Net Building Controls 0 09-17-2004 06:27 PM



Advertisments