我有一个带有范围验证器的表单:
<label class="required" for="price">price</label>
<input runat="server" id="price" name="price" type="text" required="required"/>
<asp:RangeValidator runat="server" ControlToValidate="price" ErrorMessage="Must be between 0 and 15,000" MinimumValue="0" MaximumValue="15000"></asp:RangeValidator>
但它拒绝诸如“22”和“5”之类的值,但接受值“0”和“15,000”。最重要的是,它使我的表单的提交按钮对所有输入都没有响应。为什么范围验证器不起作用?
编辑:这是表单按钮
以及当我拥有 rangevalidator 时似乎没有触发的提交功能。如果我删除 rangevalidator,此代码将执行:
protected void btnSubmit_Click(object sender, EventArgs e)
{
formInputs.Visible = false;
emailNotification.Visible = true;
MailMessage mail = new MailMessage();
mail.To.Add(emailField.Value);
mail.From = new MailAddress("no-reply@gmail.com");
mail.IsBodyHtml = true;
mail.Subject = "Your Form has been submitted";
mail.Body += "Location: ";
mail.Body += location.SelectedValue + "<br>";
mail.Body += " address: ";
mail.Body += address.Value + "<br>";
mail.Body += "price: " + price.Value + "<br>";
mail.Body += "Date submitted: " + todaysDate.Value + "<br>";
if (FileUploadControl.HasFile)
{
string filename = Path.GetFileName(FileUploadControl.FileName);
FileUploadControl.SaveAs(Server.MapPath("~/") + filename);
mail.Attachments.Add(new Attachment(HttpContext.Current.Request.MapPath(filename)));
}
SmtpClient smtp = new SmtpClient(System.Configuration.ConfigurationManager.AppSettings["mailsetting"]);
smtp.Send(mail);
}