提交表单后链接按钮的问题

本文关键字:问题 按钮 链接 表单 提交 | 更新日期: 2023-09-27 17:53:57

大家好,我有下面的代码返回到前面的表单

<asp:LinkButton ID="hlBack" runat="server" OnClientClick="history.back(); return false;" CausesValidation="false">Go Back</asp:LinkButton>
        &nbsp;<asp:LinkButton ID="lbSubmit" runat="server" OnClick="btnSubmit_Click">Submit</asp:LinkButton>

如果我没有提交表单,但在btnSubmit_Click上,我正在执行以下代码来验证

 protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string sEmails = txtareaEMail.Value;
        bool bValid = ValidateEmailAddress(sEmails);
        if (bValid)
        { }
    }
private bool ValidateEmailAddress(string sEmails)
    {
        //remove single quote from email address
        sEmails = sEmails.Replace("'", "");
        char[] delimiter = new char[] { ';' };
        string[] arPart = sEmails.Split(delimiter);
        // Create a new Regex object.
        Regex rx = new Regex(@"[0-9a-zA-Z]([-.'w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-'w]*[0-9a-zA-Z]'.)+[a-zA-Z]{2,3}");
        //only allow one email address per request
        if (arPart.Length < 1)
        {
            lblEmailMessage.Visible = true;
            lblEmailMessage.Text = "Please enter associate's email address.";
            return false;
        }
        else
        {
            for (int i = 0; i < arPart.Length; i++)
            {
                string sEmailAddress = arPart[i];
                sEmailAddress = sEmailAddress.Trim();
                if (!rx.IsMatch(sEmailAddress))
                {
                    lblEmailMessage.Visible = true;
                    lblEmailMessage.Text = sEmailAddress + " is invalid. " + "Please enter a valid email address.";
                    return false;
                }
            }
            return true;
        }
    }

当我验证它并返回false返回不工作,谁能帮助我

提交表单后链接按钮的问题

将LinkButton替换为

<a  href="#" onclick="history.go(-1);">Go Back</a>