473,651 Members | 2,512 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

protected override void CreateChildCont rols()

Jon
Hi!
I'm creating a custom Server Control which implements the method in the
subject line (Protected override void CreateChildCont rols)

In here I have the following code:

LBL myLbl = new LBL();
myLbl.ID = "MyLbl";
myLbl.Text = objCustomFieldU til.GetName("cu stom");
this.Controls.A dd(new LiteralControl( "<td class=\"regLabe lCell\">"));
this.Controls.A dd(myLbl);
this.Controls.A dd(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.Coun t; 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.



Nov 17 '05 #1
4 2459
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.A dd(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
jo***********@s urfcontrol.com

P.S. Did you do this.Controls.C lear() at the beginning of
CreateChildCont rols?

"Jon" <an**@covad.net > wrote in message
news:bg******** **@sun-news.laserlink. net...
Hi!
I'm creating a custom Server Control which implements the method in the subject line (Protected override void CreateChildCont rols)

In here I have the following code:

LBL myLbl = new LBL();
myLbl.ID = "MyLbl";
myLbl.Text = objCustomFieldU til.GetName("cu stom");
this.Controls.A dd(new LiteralControl( "<td class=\"regLabe lCell\">"));
this.Controls.A dd(myLbl);
this.Controls.A dd(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.Coun t; 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.


Nov 17 '05 #2
Jon
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.C lear(), what does that do exactly...remov e all
references to child controls on the postback?

Thanks,

Jon

"John Saunders" <jo***********@ surfcontrol.com > wrote in message
news:On******** ******@TK2MSFTN GP12.phx.gbl...
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.A dd(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
jo***********@s urfcontrol.com

P.S. Did you do this.Controls.C lear() at the beginning of
CreateChildCont rols?

"Jon" <an**@covad.net > wrote in message
news:bg******** **@sun-news.laserlink. net...
Hi!
I'm creating a custom Server Control which implements the method in

the
subject line (Protected override void CreateChildCont rols)

In here I have the following code:

LBL myLbl = new LBL();
myLbl.ID = "MyLbl";
myLbl.Text = objCustomFieldU til.GetName("cu stom");
this.Controls.A dd(new LiteralControl( "<td class=\"regLabe lCell\">"));
this.Controls.A dd(myLbl);
this.Controls.A dd(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.Coun t; 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.



Nov 17 '05 #3
"Jon" <an**@covad.net > wrote in message
news:bg******** **@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.C lear(), what does that do exactly...remov e all
references to child controls on the postback?


Controls.Clear( ) removes all of your child controls. You do it at the
beginning of CreateChildCont rols to ensure that the set of child controls is
exaclty the set created in CreateChildCont rols.

Now, I never quite tracked it down, but I've had problems with
CreateChildCont rols being called twice. Calling Controls.Clear solved the
problem.

--
John Saunders
Internet Engineer
jo***********@s urfcontrol.com

Nov 17 '05 #4
Cool, thanks for the tip and all the help.

-Jon
"John Saunders" <jo***********@ surfcontrol.com > wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
"Jon" <an**@covad.net > wrote in message
news:bg******** **@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.C lear(), what does that do exactly...remov e all references to child controls on the postback?
Controls.Clear( ) removes all of your child controls. You do it at the
beginning of CreateChildCont rols to ensure that the set of child controls

is exaclty the set created in CreateChildCont rols.

Now, I never quite tracked it down, but I've had problems with
CreateChildCont rols being called twice. Calling Controls.Clear solved the
problem.

--
John Saunders
Internet Engineer
jo***********@s urfcontrol.com


Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6468
by: Dan Cimpoiesu | last post by:
Hello What does mean when a protected modifier is apllied to a class. I want to inherit a protected class defined in another class, I saw that the microsoft programmers achieved that. But I cannot ( ex.I want to inherit the protected abstract class CollectionForm that is defined in the CollectionEditor class but I don't achieve this). Any suggestions?
4
7340
by: p988 | last post by:
using System; using System.Windows.Forms; using System.Drawing; class MyForm : Form { MyForm () { Text = "Windows Forms Demo"; }
7
7254
by: TT (Tom Tempelaere) | last post by:
Hi there The line marked *** doesn't compile. I wonder why the designers of C# decided to disallow this. Rationale? Are there plans to change this? This feature forces me to make things public when the operations are in fact protected. This breaks a lot of patterns for me public class C public void F( C other) this.G() other.G(); // **
8
11792
by: Keith Smith | last post by:
Could some one help me a little? I am trying to understand when/where you would ever want to use "protected override..." code such as this. How is this any different from creating a SelectedTextChanged type event? This is an example I found on the web... protected override void OnTextChanged(System.EventArgs e) { try
3
40343
by: gordon | last post by:
can someone please explain what protected override void is ? what is it used for? thanks Doug
0
1169
by: milmus tender | last post by:
Hi, we have some customized EditorParts, which inherits from a DefaultEditor. This DefaultEditorPart inherits from the standard EditorPart-Class. In this DefaultEditorPart we override the CreateChildControls methode to set some attributes to the div-Tag which enclose each ChildControl. Up to now we override in every customized EditorPart the CreateChildControls, but now we have to override the Render methode in one EditorPart to...
5
1893
by: =?Utf-8?B?V0o=?= | last post by:
If I have a class A that has a virtual public function DoSomething() Class A { public: virtual void DoSomething(); } then I override this function to protected is class B Class B: public Class A {
6
2482
by: REH | last post by:
Can someone please tell me what is wrong with this snippet of code? GCC is telling me that "foo2 is protected within this context" (that I cannot use it with BBB). class AAA { protected: virtual int foo2() {return 0;} };
7
3636
by: =?Utf-8?B?cmFtbzk5NDE=?= | last post by:
Hi, Is there any way disable using "protected override void OnPaint(..." method out of the assembly. I create usercontrol and i do not want user adds extra codes OnPaint method for securtity purpose. And i don't give a permission to call "CreateGraphics()". Thanks your responses.
0
8697
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8465
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7297
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5612
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4283
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1587
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.