当前位置: 首页>>代码示例>>C#>>正文


C# Validator.IsEmail方法代码示例

本文整理汇总了C#中Validator.IsEmail方法的典型用法代码示例。如果您正苦于以下问题:C# Validator.IsEmail方法的具体用法?C# Validator.IsEmail怎么用?C# Validator.IsEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Validator的用法示例。


在下文中一共展示了Validator.IsEmail方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btnOK_Click

    /// <summary>
    /// OK click hadler.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        #region "Security"

        // Check whether forum exists
        if (ForumContext.CurrentForum == null)
        {
            return;
        }

        // Check security
        bool securityCheck = true;
        switch (ForumContext.CurrentState)
        {
            case ForumStateEnum.NewThread:
                securityCheck = IsAvailable(ForumContext.CurrentForum, ForumActionType.NewThread);
                break;

            case ForumStateEnum.ReplyToPost:
                securityCheck = IsAvailable(ForumContext.CurrentForum, ForumActionType.Reply);
                break;

            case ForumStateEnum.EditPost:
                securityCheck = ForumContext.CurrentPost != null && IsAvailable(ForumContext.CurrentPost, ForumActionType.Edit);
                break;
        }

        if (!securityCheck)
        {
            lblError.Visible = true;
            lblError.Text = GetString("ForumNewPost.PermissionDenied");
            return;
        }

        #region "Captcha"

        // Check security code if is required
        if ((ForumContext.CurrentForum.ForumUseCAPTCHA) && (!SecurityCode1.IsValid()) && (ForumContext.CurrentState != ForumStateEnum.EditPost))
        {
            lblError.Visible = true;
            lblError.Text = GetString("ForumNewPost.InvalidCaptcha");
            return;
        }

        #endregion

        #region "Email field"

        // Create instance of validator
        Validator validator = new Validator();

        // Check whether email is valid
        string result = validator.IsEmail(txtEmail.Text, rfvEmail.ErrorMessage).Result;

        // Check whether email is present with correct format if email is required
        // or when subscribtion to current post is checked
        if ((ForumContext.CurrentForum.ForumRequireEmail || chkSubscribe.Checked) && (result != ""))
        {
            lblError.Visible = true;
            lblError.Text = result;
            return;
        }

        // Check if email is added if is in correct format
        if ((txtEmail.Text.Trim() != "") && (result != ""))
        {
            lblError.Visible = true;
            lblError.Text = rfvEmail.ErrorMessage;
            return;
        }

        #endregion

        #region "Subject"

        // Check whether subject is filled
        if (txtSubject.Text.Trim() == "")
        {
            lblError.Visible = true;
            lblError.Text = rfvSubject.ErrorMessage;
            return;
        }

        #endregion

        #region "Text"

        validator = new Validator();

        // Check post text in HTML editor or text area
        if (!ForumContext.CurrentForum.ForumHTMLEditor)
        {
            // Check whether post text is added in text area
            if ((result = validator.NotEmpty(DiscussionMacroHelper.RemoveTags(ucBBEditor.Text), rfvText.ErrorMessage).Result) != "")
            {
                lblError.Visible = true;
                lblError.Text = result;
//.........这里部分代码省略.........
开发者ID:v-jli,项目名称:jean0407large,代码行数:101,代码来源:NewPost.ascx.cs

示例2: btnRegister_Click

    /// <summary>
    /// On btnRegister click.
    /// </summary>
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        string currentSiteName = SiteContext.CurrentSiteName;
        // Check banned IPs
        if (!BannedIPInfoProvider.IsAllowed(currentSiteName, BanControlEnum.AllNonComplete))
        {
            lblError.Visible = true;
            lblError.Text = GetString("General.BannedIP");
            return;
        }

        // Exit if problem occurs
        if (errorOccurs)
        {
            return;
        }

        string result = null;
        Validator val = new Validator();
        // Check name fields if required
        if (RequireName)
        {
            result = val.NotEmpty(txtFirstName.Text.Trim(), GetString("eventmanager.firstnamerequired"))
                .NotEmpty(txtLastName.Text.Trim(), GetString("eventmanager.lastnamerequired")).Result;
        }
        // Check e-mail field
        if (string.IsNullOrEmpty(result))
        {
            result = val.IsEmail(txtEmail.Text.Trim(), GetString("eventmanager.emailrequired")).Result;
        }
        // Check phone field if required
        if (RequirePhone && string.IsNullOrEmpty(result))
        {
            result = val.NotEmpty(txtPhone.Text.Trim(), GetString("eventmanager.phonerequired")).Result;
        }

        if (string.IsNullOrEmpty(result))
        {
            // Allow registration if opened
            if (IsRegistrationOpened)
            {
                if (EventNode != null)
                {
                    if (!EventAttendeeInfoProvider.IsRegisteredForEvent(EventNode.NodeID, txtEmail.Text.Trim()))
                    {
                        // Add new attendant to the event
                        EventAttendeeInfo eai = AddAttendantToEvent();

                        if (eai != null)
                        {
                            // Log activity
                            Activity activity = new ActivityEventBooking(EventNode, EventNode.GetDocumentName(), eai, AnalyticsContext.ActivityEnvironmentVariables);
                            activity.Log();

                            // Send invitation e-mail
                            TimeZoneInfo tzi;
                            TimeZoneMethods.GetDateTimeForControl(this, DateTime.Now, out tzi);
                            EventProvider.SendInvitation(currentSiteName, EventNode, eai, tzi);

                            lblRegInfo.Text = GetString("eventmanager.registrationsucceeded");
                            lblRegInfo.Visible = true;
                            // Hide registration form
                            pnlReg.Visible = false;
                        }
                    }
                    else
                    {
                        // User is already registered
                        lblError.Text = GetString("eventmanager.attendeeregistered");
                        lblError.Visible = true;
                    }
                }
                else
                {
                    // Event does not exist
                    lblError.Text = GetString("eventmanager.eventnotexist");
                    lblError.Visible = true;
                    // Hide registration form
                    pnlReg.Visible = false;
                }
            }
            else
            {
                // Event registration is not opened
                lblError.Text = GetString("eventmanager.notopened");
                lblError.Visible = true;
                // Hide registration form
                pnlReg.Visible = false;
            }
        }
        else
        {
            // Display error message
            lblError.Text = result;
            lblError.Visible = true;
        }
    }
开发者ID:kbuck21991,项目名称:kentico-blank-project,代码行数:100,代码来源:EventManager.ascx.cs

示例3: btnRegister_Click

    /// <summary>
    /// On btnRegister click.
    /// </summary>
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        string currentSiteName = CMSContext.CurrentSiteName;
        // Check banned ip
        if (!BannedIPInfoProvider.IsAllowed(currentSiteName, BanControlEnum.AllNonComplete))
        {
            lblError.Visible = true;
            lblError.Text = GetString("General.BannedIP");
            return;
        }

        // Exit if problem occurs
        if (errorOccurs)
        {
            return;
        }

        string result = null;
        Validator val = new Validator();
        // Check name fields if required
        if (this.RequireName)
        {
            result = val.NotEmpty(txtFirstName.Text.Trim(), GetString("eventmanager.firstnamerequired"))
                .NotEmpty(txtLastName.Text.Trim(), GetString("eventmanager.lastnamerequired")).Result;
        }
        // Check e-mail field
        if (string.IsNullOrEmpty(result))
        {
            result = val.IsEmail(txtEmail.Text.Trim(), GetString("eventmanager.emailrequired")).Result;
        }
        // Check phone field if required
        if (this.RequirePhone && string.IsNullOrEmpty(result))
        {
            result = val.NotEmpty(txtPhone.Text.Trim(), GetString("eventmanager.phonerequired")).Result;
        }

        if (string.IsNullOrEmpty(result))
        {
            DateTime now = DateTime.Now;
            // Allow registration if opened
            if ((openFrom == DataHelper.DATETIME_NOT_SELECTED || openFrom < now) && (openTo == DataHelper.DATETIME_NOT_SELECTED || now <= openTo) && (now <= eventDate))
            {
                if (EventNode != null)
                {
                    if (!EventAttendeeInfoProvider.IsRegisteredForEvent(EventNode.NodeID, txtEmail.Text.Trim()))
                    {
                        // Add new attendant to the event
                        EventAttendeeInfo eai = AddAttendantToEvent();

                        if (eai != null)
                        {
                            // Log activity
                            if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(currentSiteName) &&
                                ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) && ActivitySettingsHelper.EventBookingEnabled(currentSiteName))
                            {
                                if (ValidationHelper.GetBoolean(EventNode.GetValue("EventLogActivity"), false))
                                {
                                    var data = new ActivityData()
                                    {
                                        ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(),
                                        SiteID = CMSContext.CurrentSiteID,
                                        Type = PredefinedActivityType.EVENT_BOOKING,
                                        TitleData = EventNode.DocumentName,
                                        ItemID = eai.AttendeeID,
                                        URL = URLHelper.CurrentRelativePath,
                                        ItemDetailID = EventNode.DocumentID,
                                        NodeID = EventNode.NodeID,
                                        Culture = EventNode.DocumentCulture,
                                        Campaign = CMSContext.Campaign
                                    };
                                    ActivityLogProvider.LogActivity(data);
                                }
                            }

                            // Send invitation e-mail
                            TimeZoneInfo tzi = null;
                            CMSContext.GetDateTimeForControl(this, DateTime.Now, out tzi);
                            EventProvider.SendInvitation(currentSiteName, EventNode, eai, tzi);

                            lblRegInfo.Text = GetString("eventmanager.registrationsucceeded");
                            lblRegInfo.Visible = true;
                            // Hide registration form
                            pnlReg.Visible = false;
                        }
                    }
                    else
                    {
                        // User is already registered
                        lblError.Text = GetString("eventmanager.attendeeregistered");
                        lblError.Visible = true;
                    }
                }
                else
                {
                    // Event does not exist
                    lblError.Text = GetString("eventmanager.eventnotexist");
                    lblError.Visible = true;
//.........这里部分代码省略.........
开发者ID:v-jli,项目名称:jean0407large,代码行数:101,代码来源:EventManager.ascx.cs


注:本文中的Validator.IsEmail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。