calling alert from code-behind
<p>i have a dropdownlist and a listbox  both asp.net controls</p>

<p>i am trying to prevent the user add duplciate items to listbox control</p>

<p>i able to block it but i want to display DIV or Alert box saying,"duplciate names are not allowed"</p>

<pre><code>protected void btn_AddRecipientAction_OnClick(object sender, EventArgs e)
        {
            if (Convert.ToInt32(this.ddlRecipient.SelectedValue) &gt; 0)
            {
                if (ddlRecipient.Text.Length &gt; 0)
                {
                    //var items = new System.Collections.ArrayList(this.lstRecipient.Items);  
                    for(var i = lstRecipient.Items.Count - 1; i &gt;= 0; --i) 
                    {                      
                        if (lstRecipient.Items[i].Text == ddlRecipient.SelectedItem.Text)
                        {
                            lstRecipient.Items.RemoveAt(i);
                            **//alert("duplicate entry not allowed")
                            //div display the message and disappears after few seconds?**
                        } 
                    } 
                    ListItem newList = new ListItem();
                    newList.Text = ddlRecipient.SelectedItem.Text;
                    newList.Value = ddlRecipient.SelectedValue;
                    this.lstRecipient.Items.Add(newList);
                }


            } 
        }
</code></pre>
