验证控件应该是在客户端检验的,不用提交到服务器的
但是,我做了个非空的验证控件,放到网站空间里,点提交时,他要提交到服务器(IE状态栏里看到重新打开页面),然后显示验证非空的红字
但是在本地用http://localhost 时,不会向上提交,就直接显示非空的红字为什么放到网站空间里,会出现这个问题呢??怎么解决??
但是,我做了个非空的验证控件,放到网站空间里,点提交时,他要提交到服务器(IE状态栏里看到重新打开页面),然后显示验证非空的红字
但是在本地用http://localhost 时,不会向上提交,就直接显示非空的红字为什么放到网站空间里,会出现这个问题呢??怎么解决??
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 296px; POSITION: absolute; TOP: 80px" runat="server"></asp:TextBox>
<asp:TextBox id="TextBox2" style="Z-INDEX: 102; LEFT: 304px; POSITION: absolute; TOP: 128px"
runat="server"></asp:TextBox>
<asp:RequiredFieldValidator id="RequiredFieldValidator1" style="Z-INDEX: 103; LEFT: 480px; POSITION: absolute; TOP: 80px"
runat="server" ErrorMessage="非空!" ControlToValidate="TextBox1"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator id="RequiredFieldValidator2" style="Z-INDEX: 104; LEFT: 488px; POSITION: absolute; TOP: 136px"
runat="server" ErrorMessage="非空!" ControlToValidate="TextBox2"></asp:RequiredFieldValidator>
<asp:Button id="Button1" style="Z-INDEX: 105; LEFT: 320px; POSITION: absolute; TOP: 192px" runat="server"
Text="提交"></asp:Button>
<asp:Label id="Label1" style="Z-INDEX: 106; LEFT: 320px; POSITION: absolute; TOP: 272px" runat="server"
Width="144px"></asp:Label></FONT>
</form>
</body>后台:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace test
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
if(Page.IsValid)
{
this.Label1.Text="通过验证!!!";
}
}
}
}
WebUIValidation.js文件和你本地的不一样
应该就是这个原因