mephistophel
New Member
I am stuck with a problem which I have reduced to code below . I have two buttons on an aspx page.Both the buttons have \[code\]runat="server"\[/code\] property and are inside \[code\]<form runat="server" >\[/code\] tagbtnGetData\[code\] protected void btnGetData_Click(object sender, EventArgs e) { headlines = masg.Split('*'); //Response.Write(headlines.Length); cb = new CheckBox[headlines.Length]; for (int i = 0; i < headlines.Length; i++) { cb = new CheckBox(); cb.Text = headlines; Literal br = new Literal(); br.Text = "<br/>"; Form.Controls.Add(cb); Form.Controls.Add(br); } } \[/code\]On clicking Get Data button , multiple checkboxes are generated with associated text .I click on some of the checkboxes and then click on Show button which IF WORKS CORRECTLY should combine selected checboxes text into single string and display it.btnShow\[code\]protected void btnShow_Click(object sender, EventArgs e){ for (int i = 0; i < headlines.Length; i++) { if (cb.Checked) newmsg += cb.Text + '*'; } Response.Write("<BR><BR><BR>" + newmsg);}\[/code\]But once I click on GetData button , the checkboxes are lost as they don't persist . I read about \[code\]SESSION\[/code\] variables but can't figure out how to apply them . I have declared below variables as global so that they can be accessed throughout the page.\[code\]CheckBox[] cb;string[] headlines;string masg;\[/code\]Please help with code .Please provide me with inputs in code. I will refine my question if I am not able to make something clear.