C# rangevalidator拒绝错误的值并使我的提交按钮无响应

C# rangevalidator拒绝错误的值并使我的提交按钮无响应,c#,asp.net,visual-studio-2010,C#,Asp.net,Visual Studio 2010,我有一个带有范围验证器的表单: <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

我有一个带有范围验证器的表单:

<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”和“15000”。最重要的是,它使我的表单的提交按钮对所有输入都没有响应。为什么范围验证器不能工作

编辑:这是表单按钮

还有提交功能,当我使用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);   
}     
protectedvoid btnSubmit\u单击(对象发送方,事件参数e)
{
formInputs.Visible=false;
emailNotification.Visible=true;
MailMessage mail=新的MailMessage();
mail.To.Add(emailField.Value);
mail.From=新邮件地址(“否-reply@gmail.com");
mail.IsBodyHtml=true;
mail.Subject=“您的表格已提交”;
mail.Body+=“位置:”;
mail.Body+=location.SelectedValue+“
”; 邮件正文+=“地址:”; mail.Body+=address.Value+“
”; mail.Body+=“价格:”+price.Value+“
”; mail.Body+=“提交日期:”+todaysDate.Value+“
”; if(FileUploadControl.HasFile) { 字符串filename=Path.GetFileName(FileUploadControl.filename); FileUploadControl.SaveAs(Server.MapPath(“~/”)+文件名); mail.Attachments.Add(新附件(HttpContext.Current.Request.MapPath(文件名)); } SmtpClient smtp=新的SmtpClient(System.Configuration.ConfigurationManager.AppSettings[“mailsetting”]); smtp.发送(邮件); }
在验证器中指定Type=“Integer”,因为您没有指定类型。它可能将类型作为字符串,这就是它未按预期进行验证的原因

您拥有的验证器将进行如下修改

<asp:RangeValidator runat="server" Type="Integer" ControlToValidate="price" ErrorMessage="Must be between 0 and 15,000" MinimumValue="0" MaximumValue="15000"></asp:RangeValidator>


解决了第一个问题,但由于某些原因,它仍然使“我的提交”按钮没有响应。如果按钮没有响应,您可以发布代码吗?只需注释最后一条语句smtp.Send(mail);我认为这可能是页面无响应的原因,并且在我删除onclick事件和函数代码时,将代码放入try-catch-blockRemove/Comment-all-from-button-event和tryStill-unresponse中。但是当我移除rangevalidator时,它又开始响应了。