Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/394.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ASP.NET:客户端验证、服务器端操作_C#_Javascript_Jquery_.net_Web Applications - Fatal编程技术网

C# ASP.NET:客户端验证、服务器端操作

C# ASP.NET:客户端验证、服务器端操作,c#,javascript,jquery,.net,web-applications,C#,Javascript,Jquery,.net,Web Applications,出于某种原因,我将HTML控件与runat=“server”一起使用。其中一个控件是按钮。我有客户端验证功能。在客户端验证成功后,我不想启动服务器端操作 HTML: <button type="button" id="webSubmit" runat="server" onclick="return $('#form1').valid();">Submit</button> protected void webSubmit_ServerClick(object se

出于某种原因,我将HTML控件与
runat=“server”
一起使用。其中一个控件是按钮。我有客户端验证功能。在客户端验证成功后,我不想启动服务器端操作

HTML:

<button type="button" id="webSubmit" 
runat="server" 
onclick="return $('#form1').valid();">Submit</button>
protected void webSubmit_ServerClick(object sender, EventArgs e)
{
   //foo
}
当我单击按钮时,它会验证表单,但即使验证返回true,也不会回发

它是由ASP.net生成的:

<button onclick="return $('#form1').valid(); __doPostBack('webSubmit','')" 
id="webSubmit" type="button">Submit</button>
提交

我将一次点击代码更改为:

onclick="$('#form1').valid() && "
ASP.net生成的代码是:

<button onclick="$('#form1').valid() &&  __doPostBack('webSubmit','')" 
id="webSubmit" type="button">Submit</button>

我的想法来源于:

你有什么
按钮。使用submitbehavior属性设置是否正确。。?
if ($('#form1').valid()){
__doPostBack('webSubmit','')
}