来自数据库的值时,如何验证来自用户的输入 [英] How Can I Validate Input From User When The Values From Database

查看:90
本文介绍了来自数据库的值时,如何验证来自用户的输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个销售页面,可以从数据库中检索商品和那里的价格.
就像我修改商品代码时,它会在文本框中检索商品名称及其汇率.
现在的问题是我的用户想要更改从数据库中检索的速率.
假设项目名称为Book,其比率为100.用户希望将比率从100更改为101或110 0r,将其值设置为大于100或等于100.
所以我的问题是他该怎么做.假设他选择了100(从数据库自动检索)或超过100,则允许他.当他选择或输入的值小于100时,将生成一条错误消息.
当从数据库中检索到的值将由客户端的用户进行编辑,并且将返回并回发进行比较时,将类似于此,如果该值小于检索到的值,则返回一个错误脚本将显示.如果该值等于或大于该值,它将继续使用户输入另一个凭据.
给我逻辑或代码怎么做.
我正在使用VS 2010和SQL Server2008.

i have a sale page where the item and there rate is retrieved from database.
like when i wright a item code it retrieve the item name along with its rate on the text boxes.
now problem is that my user want to change the rate so retrieved from database.
suppose item name is Book and its rate is 100. user want to change the rate from 100 to 101 or 110 0r any value more than 100 or equal to 100.
so my question is this that how can he do it. suppose if he chose 100(which is automatic retrieved from database) or more than 100 he is allowed. and when he chooses or enter value less then 100 an error message get generated.
this will go like this when the value so retrieved from the database will be edited by user at the client side and this will get post back and this post back will do the comparison,if the value is less then the retrieved one then an error script will be displayed. and if the value is equal or more then it will continue the user to enter another credentials.
give me logic or code how to go for it.
i am using VS 2010 and SQL server 2008.

推荐答案

您好,

您可以在VS中使用"Rangevalidator"控件,该控件将允许您验证范围及其客户端验证.但是对于服务器端验证,Javascript将需要验证范围.
Hello,

You can use "Rangevalidator" control in VS which will allow you to validation range and its an client side validation .But for Server side validation Javascript will require to validate the range.


报价:

< asp:comparevalidator id ="CompareValidator1" runat ="server" xmlns:asp =#unknown">
ErrorMessage ="*您应该输入等于或大于旧值的值" ControlToValidate ="TextBox2" ControlToCompare ="TextBox1" Operator ="GreaterThanEqual" Type ="Integer">

<asp:comparevalidator id="CompareValidator1" runat="server" xmlns:asp="#unknown">
ErrorMessage="*you should input value equal to or grater then old value" ControlToValidate="TextBox2" ControlToCompare="TextBox1" Operator="GreaterThanEqual" Type="Integer">


这篇关于来自数据库的值时,如何验证来自用户的输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆