Displaying checked items as alert.

2 posts, 1 answers
  1. Anly
    Anly avatar
    14 posts
    Member since:
    Feb 2013

    Posted 04 Apr 2013 Link to this post

    Hello,

    There is a RadCombobox with check-boxes enabled in my project. There is another RadButton and on server side clicking the button, I want to display an alert that contains the checked item text from the RadCombobox for ex "You have selected Item1, Item2". Please help me with any sample solution.

    Thanks in advance,
    Anly.
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 04 Apr 2013 Link to this post

    Hi Anly,

    Please check the following sample C# code.

    C#:
    protected void RadButton1_Click(object sender, EventArgs e)
    {
        string selectedItems=string.Empty;
        string alert;
        foreach (var items in RadComboBox1.CheckedItems)
        {
            selectedItems = selectedItems + items.Text + ", ";   
        }
        alert = "You have Checked " + selectedItems;
        Page.ClientScript.RegisterStartupScript(this.GetType(), "click", "alert('"+alert+"');", true);
    }

    Thanks,
    Princy.
Back to Top