Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

hai,

 

i am generating check boxes dynamically (code is given below) i wanted to capture the check box checked status plz help me how to do this, dont consider that i have given both text property and ID are same as this i am testing i have given this

 

CheckBox chk;

chk = new CheckBox;

DateTime dt = DateAndTime.DateAdd(DateInterval.Day, 1, date1);

String str = dt.ToString("D");

String[] abc = str.Split(new Char[] { ',' });

Panel1.Controls.Add(chk);

chk.ID=abc[0];

chk.Text=abc[0];

chk.Width=150;

chk.Height=50;

 

If Possible give me sample example

  • 2 weeks later...
Posted

If you are dealing with dynamically created controls you need to be aware of the life cycle of the page to make sure the state gets persisted.

 

Do an image search for "ASP.Net page lifecycle", a must have resource for asp.net programmer.

 

You'll see the state is persisted between OnInit and Load. Therefore, for you checkbox to have the state set automgically you'll need to create it in OnInit and then you can access the value after the Load event. I suspect that's your problem but you haven't shown when or how you are getting the value.

 

 

Alternatively you can get it yourself from the request if you know the client ID of the control.

string value = Context.Request.Form["clientId"];

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...