这是我的关于一个自定义验证控件的程序:
<%@ Page Language="C#" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">
void CustomValidator1_ServerValidate(object sender, ServerValidateEventArgs e)
{
int num =Int32.Parse(Args.Value);
if(num%2==0)
{
Args.IsValid=true;return;
}
Args.IsValid=false;
}
void Button1_Click(object sender, EventArgs e)
{
if(Page.IsValid)
{
Lable1.Text="输入数据是:"+TextBox1.Text;
}
}</script>
<html>
<head>
</head>
<body>
<form runat="server">
<table height="90" width="500" align="center">
<tbody>
<tr>
<td>
<asp:Label id="Label1" runat="server" borderstyle="Dotted" font-size="Small" font-names="楷体_GB2312">使用CustomValidator数据验证控件</asp:Label></td>
</tr>
<tr>
<td>
<asp:Label id="Label2" runat="server">请输入一个偶数:</asp:Label>
<asp:TextBox id="TextBox1" runat="server" MaxLength="20"></asp:TextBox>
<asp:CustomValidator id="CustomValidator1" runat="server" OnServerValidate="CustomValidator1_ServerValidate" ErrorMessage="必须输入偶数"></asp:CustomValidator>
</td>
</tr>
<tr>
<td>
<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="提交"></asp:Button>
</td>
</tr>
<tr>
<td>
<asp:Label id="Label3" runat="server"></asp:Label></td>
</tr>
</tbody>
</table>
<!-- Insert content here -->
</form>
</body>
</html>
提示错误:Compiler Error Message: CS0246: The type or namespace name 'Args' could not be found (are you missing a using directive or an assembly reference?)
int num =Int32.Parse(Args.Value);——这一行出错
<%@ Page Language="C#" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">
void CustomValidator1_ServerValidate(object sender, ServerValidateEventArgs e)
{
int num =Int32.Parse(Args.Value);
if(num%2==0)
{
Args.IsValid=true;return;
}
Args.IsValid=false;
}
void Button1_Click(object sender, EventArgs e)
{
if(Page.IsValid)
{
Lable1.Text="输入数据是:"+TextBox1.Text;
}
}</script>
<html>
<head>
</head>
<body>
<form runat="server">
<table height="90" width="500" align="center">
<tbody>
<tr>
<td>
<asp:Label id="Label1" runat="server" borderstyle="Dotted" font-size="Small" font-names="楷体_GB2312">使用CustomValidator数据验证控件</asp:Label></td>
</tr>
<tr>
<td>
<asp:Label id="Label2" runat="server">请输入一个偶数:</asp:Label>
<asp:TextBox id="TextBox1" runat="server" MaxLength="20"></asp:TextBox>
<asp:CustomValidator id="CustomValidator1" runat="server" OnServerValidate="CustomValidator1_ServerValidate" ErrorMessage="必须输入偶数"></asp:CustomValidator>
</td>
</tr>
<tr>
<td>
<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="提交"></asp:Button>
</td>
</tr>
<tr>
<td>
<asp:Label id="Label3" runat="server"></asp:Label></td>
</tr>
</tbody>
</table>
<!-- Insert content here -->
</form>
</body>
</html>
提示错误:Compiler Error Message: CS0246: The type or namespace name 'Args' could not be found (are you missing a using directive or an assembly reference?)
int num =Int32.Parse(Args.Value);——这一行出错
解决方案 »
- 在winform中怎么设置一个按键刷新本窗体的数据?
- 如何使两个一样的panel同步竖直滚动
- VB封装的VBA代码在VSTO中的问题
- Asp.net栏中无人搞定,来这继续提问。高分奉上(加上另一帖的)!
- 记事本程序中如何控制光标?
- 在C#.net 2005中的DataGrid中 怎样给手工添加上去的ComboBoxColumn添加选项
- 如何用c#将一个文件夹,备份成一个文件呢
- QQ好友比对程序
- c#访问oracle问题急!!!!
- 如何用c#编写一个服务,每天定时启动执行一个任务?哪位老大有例子程序?谢谢。
- 一个简单的问题(你们得体会是??)!!!
- 请教!c#中想使用“打开”对话框和写INI文件冲突
那应该怎样改?
是什么意思,特别是那个e
错误提示:System.FormatException: Input string was not in a correct format.