Reply
Putting the Page_Load event and set Label text on all pages
Old 06-16-2009, 08:07 AM Putting the Page_Load event and set Label text on all pages
Junior Talker

Posts: 3
Name: diamond
Trades: 0
I want to define the Label text dynamically from database, and loop all the Label contorl in the content.
How can i put the Page_Load function to all of my page?
foreach (Control ctrl in Page.Controls)
{
foreach (Control ctrl0 in ctrl.Controls)
{
//ctrl0

if (ctrl0.GetType() == typeof(Label))
//Load DB text
ctrl0.Text = db.Text;
}

}
__________________
contact center
diamondrajoor is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 06-18-2009, 11:07 AM Re: Putting the Page_Load event and set Label text on all pages
Skilled Talker

Posts: 69
Trades: 0
Be careful with this as you'll quickly find out that if you bind to a repeater none of your labels will show. Something like the following would be my guess.

LabelFromDB(control parent)
{
foreach(control c in parent.controls)
{
if(c.HasControls)
{
LabelFromDB(c);
}
}
}

You'll also want a check to see if c is a label and if so fill it with text.
stbuchok is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Putting the Page_Load event and set Label text on all pages
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.10460 seconds with 13 queries