.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 20th, 2005, 03:40 AM
kingchugg kingchugg is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 7 kingchugg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 12 m 12 sec
Reputation Power: 0
referencing dynamically created controls

I have web form, which has some of its content created dynamically. I need to access these items when a button is clicked (in the onclick event). So far I have drawn a blank.
Here is the code for the creation (in pre_render):

// Selected col
CheckBox cb = new CheckBox();
cb.ID = "cbxSub" + _Ids.Keys[ i ];
cb.Text = "";
TableCell cSub = new TableCell();
cSub.Controls.Add( cb );
row.Cells.Add( cSub );

And teh code to get the state of the control (onclick):


foreach ( Control ctrl in Page.Controls)
{
if (ctrl is CheckBox)
if ((ctrl as CheckBox).Checked)
if ((ctrl.ID != null) && (ctrl.ID.Length > 6) && (ctrl.ID.Substring( 0, 6 ) == "cbxSub"))
Session[ ctrl.ID ] = "true";
}

What am I doing wrong?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > referencing dynamically created controls


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT