English 中文(简体)
牧场主拒绝接受错误的价值观,使我提交纽芬兰语
原标题:rangevalidator rejects wrong values and makes my submit button unresponsive

我的表格有一系列有效者:

<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。 首先,它使我的形式对所有投入都不敏感。 为什么限制有效者工作?

Edit: Here s the form button

在我拥有散射机时,似乎已经停电的提交功能。 如果我去除切割器,该法典将执行:

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("[email protected]");
                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);   
}     
问题回答

有效器中的“Integer”类型,因为你没有给出这种类型。 可能采取说明的形式,这就是为什么没有按预期进行验证。

您的验证人将作此修改。

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




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签