asp.net 的
解决方案 »
- 庖丁解牛分词和mmseg4j分词器怎么转换成.net版本能用?或者说谁有.NET版本的这些分词?
- repeater 导数excl 怎么是这种格式,请大家帮帮忙。谢谢。。
- updatepanel 里放datalist Event触发后postback,Page_load被执行?小弟百思不得其解?
- 小问题
- asp.net的自我介绍
- form验证的一个webapplicaton 能否有2个login界面?
- 按扭添加WINDOW.CLOSE()问题,求助
- dropdownlist控件如何既绑定数据表的数据又添加说明项目
- 对服务器上的数据库记录更新问题目。
- Include file within aspx
- 找不到类型或命名空间名称“DataBase”
- 错误提示:machine.config could not be loaded. Attempted to access an unloaded AppDomain
{
int i=Int32.Parst(TestBox1.text);
}
catch
{
Response.Write("输入的不是整数");
}
也可以用js函数来验证取值用正则式去匹配
d{6}表示6位整数
<asp:RegularExpressionValidator
ID="RegularExpressionValidator4" runat="server" ControlToValidate="Text13" ErrorMessage="必为数字!"
ValidationExpression="[0-9]*$"></asp:RegularExpressionValidator>
方法1、Int32.Parst
try
{
int i=Int32.Parst(TestBox1.text);
}
catch
{
Response.Write("输入的不是整数");
} 优点:后台方法,简单易懂。缺点:要刷页面,很多时候我们做验证是不要求刷页面的,
方法2、正则表达式——验证控件<input name="textfield12" type="text" size="30" id="Text13" runat="server" />
<asp:RegularExpressionValidator
ID="RegularExpressionValidator4" runat="server" ControlToValidate="Text13" ErrorMessage="必为数字!"
ValidationExpression="[0-9]*$"> </asp:RegularExpressionValidator>
优点:方便、易用、简单、不刷页面。方法3、正则表达式——js
<input name="textfield12" type="text" size="30" id="Text13" runat="server" onclick="check()" />
<script language="javascript">
function check()
{
var Expression = "/^\d{1,3}$/";
if(Text13.value != "")
{
if(!Text13.value.match(Expression))
alert("输入错误,为整数!!");
}
}
</script>
很多人喜欢验证控件,有的喜欢用js,自己选择
function myKeyDown()
{
var k=window.event.keyCode; if ((k==46)||(k==8)||(k==189)||(k==109)||(k==190)||(k==110)|| (k>=48 && k<=57)||(k>=96 && k<=105)||(k>=37 && k<=40))
{}
else if(k==13){
window.event.keyCode = 9;}
else{
window.event.returnValue = false;}
}
</script><asp:TextBox Runat="server" id="TT" style="ime-mode:disabled" onkeydown="myKeyDown()"></asp:textBox>
{
//是整数
}
else
{
//不是整数
}