Ask a Question related to ASP.NET General, Design and Development.
-
Jon #1
protected override void CreateChildControls()
Hi!
I'm creating a custom Server Control which implements the method in the
subject line (Protected override void CreateChildControls)
In here I have the following code:
LBL myLbl = new LBL();
myLbl.ID = "MyLbl";
myLbl.Text = objCustomFieldUtil.GetName("custom");
this.Controls.Add(new LiteralControl("<td class=\"regLabelCell\">"));
this.Controls.Add(myLbl);
this.Controls.Add(new LiteralControl("</td>"));
Now what I'd like to do is add the child controls dynamically by looping
through a Data Table:
for(int i = 0; i < objDT.Rows.Count; i++)
{
//Implement Adding Controls here
}
The problem arises that I need to declare my label or textbox before I can
added it. Anyone know a way around this?
Thank you.
Jon Guest
-
properties going to void
"Stephen Whipp" <Stephen.Whipp@btopenworld.com> wrote in message news:bkt355$p90$1@forums.macromedia.com... Are you sure the marker isn't on the... -
Should VOID = 0?
Just wondering what you think about VOID being equal to 0? Personally I wish that void didn't equal 0 as it can cause problems for some checks,... -
voidP() and variable = VOID with integers with a value of 0
note that voidp(whatever) is a function returning true (1) if 'whatever' is equivalent to VOID. when you do: put vZero = VOID the program... -
CreateChildControls?
Hi. I have an HTML page were I load controls dynamically. So I overwrote the CreateChildControl but I found some problem. First time when page... -
Static void
Hi, In a gnu/linux env, I have a library exposes one function foo() to a multithreaded server application. Here are my questions: 1. any... -
John Saunders #2
Re: protected override void CreateChildControls()
Jon, it's not a problem:
for(into I = 0; I < bond.Rows.Count; I++)
{
Label aspLabel = new Label();
aspLabel.ID = "Label" + I.ToString();
aspLabel.Text = bond.Rows[I]["field"];
this.Controls.Add(aspLabel);
}
Of course, you want to do this in the right place, and maybe you want to
enclose each label in a "<td></td>".
--
John Saunders
Internet Engineer
[email]john.saunders@surfcontrol.com[/email]
P.S. Did you do this.Controls.Clear() at the beginning of
CreateChildControls?
"Jon" <anon@covad.net> wrote in message
news:bgs54n$v6n$1@sun-news.laserlink.net...the> Hi!
> I'm creating a custom Server Control which implements the method in> subject line (Protected override void CreateChildControls)
>
> In here I have the following code:
>
> LBL myLbl = new LBL();
> myLbl.ID = "MyLbl";
> myLbl.Text = objCustomFieldUtil.GetName("custom");
> this.Controls.Add(new LiteralControl("<td class=\"regLabelCell\">"));
> this.Controls.Add(myLbl);
> this.Controls.Add(new LiteralControl("</td>"));
>
> Now what I'd like to do is add the child controls dynamically by looping
> through a Data Table:
>
> for(int i = 0; i < objDT.Rows.Count; i++)
> {
> //Implement Adding Controls here
> }
>
> The problem arises that I need to declare my label or textbox before I can
> added it. Anyone know a way around this?
>
> Thank you.
>
>
>
>
>
>
>
John Saunders Guest
-
Jon #3
Re: protected override void CreateChildControls()
John,
Thanks...Sorry for not trying that first (makes me look like a
dumba$$ In my defense it was late and I was on the way out :-) )
I did not do this.Controls.Clear(), what does that do exactly...remove all
references to child controls on the postback?
Thanks,
Jon
"John Saunders" <john.saunders@surfcontrol.com> wrote in message
news:OnUoifIXDHA.1492@TK2MSFTNGP12.phx.gbl...can> Jon, it's not a problem:
>
> for(into I = 0; I < bond.Rows.Count; I++)
> {
> Label aspLabel = new Label();
> aspLabel.ID = "Label" + I.ToString();
> aspLabel.Text = bond.Rows[I]["field"];
> this.Controls.Add(aspLabel);
> }
>
> Of course, you want to do this in the right place, and maybe you want to
> enclose each label in a "<td></td>".
> --
> John Saunders
> Internet Engineer
> [email]john.saunders@surfcontrol.com[/email]
>
> P.S. Did you do this.Controls.Clear() at the beginning of
> CreateChildControls?
>
> "Jon" <anon@covad.net> wrote in message
> news:bgs54n$v6n$1@sun-news.laserlink.net...> the> > Hi!
> > I'm creating a custom Server Control which implements the method in> > subject line (Protected override void CreateChildControls)
> >
> > In here I have the following code:
> >
> > LBL myLbl = new LBL();
> > myLbl.ID = "MyLbl";
> > myLbl.Text = objCustomFieldUtil.GetName("custom");
> > this.Controls.Add(new LiteralControl("<td class=\"regLabelCell\">"));
> > this.Controls.Add(myLbl);
> > this.Controls.Add(new LiteralControl("</td>"));
> >
> > Now what I'd like to do is add the child controls dynamically by looping
> > through a Data Table:
> >
> > for(int i = 0; i < objDT.Rows.Count; i++)
> > {
> > //Implement Adding Controls here
> > }
> >
> > The problem arises that I need to declare my label or textbox before I>> > added it. Anyone know a way around this?
> >
> > Thank you.
> >
> >
> >
> >
> >
> >
> >
>
Jon Guest
-
John Saunders #4
Re: protected override void CreateChildControls()
"Jon" <anon@covad.net> wrote in message
news:bgu4nh$9am$1@sun-news.laserlink.net...Controls.Clear() removes all of your child controls. You do it at the> John,
> Thanks...Sorry for not trying that first (makes me look like a
> dumba$$ In my defense it was late and I was on the way out :-) )
>
> I did not do this.Controls.Clear(), what does that do exactly...remove all
> references to child controls on the postback?
beginning of CreateChildControls to ensure that the set of child controls is
exaclty the set created in CreateChildControls.
Now, I never quite tracked it down, but I've had problems with
CreateChildControls being called twice. Calling Controls.Clear solved the
problem.
--
John Saunders
Internet Engineer
[email]john.saunders@surfcontrol.com[/email]
John Saunders Guest
-
Jonathan Williams #5
Re: protected override void CreateChildControls()
Cool, thanks for the tip and all the help.
-Jon
"John Saunders" <john.saunders@surfcontrol.com> wrote in message
news:%23ZWxvDRXDHA.1644@TK2MSFTNGP10.phx.gbl...all> "Jon" <anon@covad.net> wrote in message
> news:bgu4nh$9am$1@sun-news.laserlink.net...> > John,
> > Thanks...Sorry for not trying that first (makes me look like a
> > dumba$$ In my defense it was late and I was on the way out :-) )
> >
> > I did not do this.Controls.Clear(), what does that do exactly...removeis>> > references to child controls on the postback?
> Controls.Clear() removes all of your child controls. You do it at the
> beginning of CreateChildControls to ensure that the set of child controls> exaclty the set created in CreateChildControls.
>
> Now, I never quite tracked it down, but I've had problems with
> CreateChildControls being called twice. Calling Controls.Clear solved the
> problem.
>
> --
> John Saunders
> Internet Engineer
> [email]john.saunders@surfcontrol.com[/email]
>
>
>
Jonathan Williams Guest



Reply With Quote

