/// <summary> /// Handles the OnEntryAdded event of the racbRecipientsPopup control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Telerik.Web.UI.AutoCompleteEntryEventArgs"/> instance containing the event data.</param> protected void racbRecipientsPopup_OnEntryAdded(object sender, AutoCompleteEntryEventArgs e) { var recipient = new SiteActionTemplateRecipientMap { Key = e.Entry.Value }; if (string.IsNullOrEmpty(e.Entry.Value)) { if (Regex.IsMatch(e.Entry.Text, @"^(?("")("".+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$")) { recipient.Email = e.Entry.Text; RecipientsPopupList.Add(recipient); } } else { var val = e.Entry.Value.Split('|'); switch (val[0]) { case "Contact": recipient.ContactID = val[1].ToGuid(); break; case "Role": recipient.ContactRoleID = val[1].ToGuid(); break; } RecipientsPopupList.Add(recipient); } if (!Page.ClientScript.IsStartupScriptRegistered(this.ClientID + "_AutoHeight")) { ScriptManager.RegisterStartupScript(Page, typeof(Page), this.ClientID + "_AutoHeight", this.ClientID + "_AutoHeight();", true); } }
/// <summary> /// Handles the OnClick event of the rbAddRole control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void rbAddRole_OnClick(object sender, EventArgs e) { var entry = new AutoCompleteBoxEntry { Text = dcbContactRolePopup.SelectedText, Value = "Role|" + dcbContactRolePopup.SelectedId }; racbRecipientsPopup.Entries.Add(entry); RecipientsPopupList.Add(new SiteActionTemplateRecipientMap { ContactRoleID = dcbContactRolePopup.SelectedId, Key = "Role|" + dcbContactRolePopup.SelectedId }); if (!Page.ClientScript.IsStartupScriptRegistered(this.ClientID + "_AutoHeight")) { ScriptManager.RegisterStartupScript(Page, typeof(Page), this.ClientID + "_AutoHeight", this.ClientID + "_AutoHeight();", true); } }
/// <summary> /// Handles the OnEntryRemoved event of the racbRecipientsPopup control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Telerik.Web.UI.AutoCompleteEntryEventArgs"/> instance containing the event data.</param> protected void racbRecipientsPopup_OnEntryRemoved(object sender, AutoCompleteEntryEventArgs e) { if (!string.IsNullOrEmpty(e.Entry.Value)) { RecipientsPopupList.RemoveAll(a => a.Key == e.Entry.Value); } else { RecipientsPopupList.RemoveAll( a => a.Email == e.Entry.Text || "<" + a.Email + ">" == e.Entry.Text || (!string.IsNullOrEmpty(a.DisplayName) ? string.Format("{0} <{1}>", a.DisplayName, a.Email) : string.Format("<{0}>", a.Email)) == e.Entry.Text); } if (!Page.ClientScript.IsStartupScriptRegistered(this.ClientID + "_AutoHeight")) { ScriptManager.RegisterStartupScript(Page, typeof(Page), this.ClientID + "_AutoHeight", this.ClientID + "_AutoHeight();", true); } }
/// <summary> /// Handles the OnClick event of the rbAddCustom control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void rbAddCustom_OnClick(object sender, EventArgs e) { var entryText = !string.IsNullOrEmpty(txtDisplayNamePopup.Text) ? string.Format("{0} <{1}>", txtDisplayNamePopup.Text, txtEmailPopup.Text) : string.Format("<{0}>", txtEmailPopup.Text); var entry = new AutoCompleteBoxEntry { Text = entryText }; racbRecipientsPopup.Entries.Add(entry); RecipientsPopupList.Add(new SiteActionTemplateRecipientMap { Email = txtEmailPopup.Text, DisplayName = !string.IsNullOrEmpty(txtDisplayNamePopup.Text) ? txtDisplayNamePopup.Text : null }); txtEmailPopup.Text = string.Empty; txtDisplayNamePopup.Text = string.Empty; if (!Page.ClientScript.IsStartupScriptRegistered(this.ClientID + "_AutoHeight")) { ScriptManager.RegisterStartupScript(Page, typeof(Page), this.ClientID + "_AutoHeight", this.ClientID + "_AutoHeight();", true); } }