Пример #1
0
        /// <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);
            }
        }
Пример #2
0
        /// <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);
            }
        }
Пример #3
0
        /// <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 || "&lt;" + a.Email + "&gt;" == e.Entry.Text ||
                    (!string.IsNullOrEmpty(a.DisplayName)
                         ? string.Format("{0} &lt;{1}&gt;", a.DisplayName, a.Email)
                         : string.Format("&lt;{0}&gt;", a.Email)) == e.Entry.Text);
            }

            if (!Page.ClientScript.IsStartupScriptRegistered(this.ClientID + "_AutoHeight"))
            {
                ScriptManager.RegisterStartupScript(Page, typeof(Page), this.ClientID + "_AutoHeight", this.ClientID + "_AutoHeight();", true);
            }
        }
Пример #4
0
        /// <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} &lt;{1}&gt;", txtDisplayNamePopup.Text, txtEmailPopup.Text)
                                : string.Format("&lt;{0}&gt;", 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);
            }
        }