I have some check boxes.I want to print text of selected check boxes of the page.Code which I wrote is neither giving error nor giving correct output .Please help me .Here is the code
protected void btnSelect_Click1(object sender, EventArgs e)
{
string strchkSelected = "";
foreach (Control ctl in Page.Controls)
{
if (ctl is CheckBox)
{
if(((CheckBox)ctl).Checked)
{
strchkSelected += ((CheckBox)ctl).Text + " ";
}
}
}
Response.Write(strchkSelected);
}