aspx page code:
<asp:CheckBoxList ID="CheckBoxList1" runat="server">
<asp:ListItem Text="Apple" Value="Apple"></asp:ListItem>
<asp:ListItem Text="Banana" Value="Banana"></asp:ListItem>
<asp:ListItem Text="Orange" Value="Orange"></asp:ListItem>
</asp:CheckBoxList>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
code behind(aspx.cs):
protected void Button1_Click(object sender, EventArgs e)
{
string abc = "";
foreach (ListItem item in CheckBoxList1.Items)
{
if (item.Selected)
{
abc += item.Value + ',';
}
}
string test = "you have selected " + abc;
Label labelshow = new Label();
labelshow.Text = "<script language='javascript'>" + Environment.NewLine + "window.alert('" + test + "')</script>";
Page.Controls.Add(labelshow);
}
is this what you were looking for? Hope it Helps!