文本框客户端验证和服务器验证无效 [英] Textbox client validation and server validation not working

查看:52
本文介绍了文本框客户端验证和服务器验证无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < script    类型  =  text / javascript >  

函数here()
{
return (确认( 你想要));
}

< / script >



这是我的文本框...

 < asp:TextBox ID =   TextBox1 Onchange =    return here() runat =   server 
AutoPostBack = True ontextchanged = TextBox1_TextChanged >



这是我的cs代码

 受保护  void  TextBox1_TextChanged( object  sender,EventArgs e)
{
Response.Write( 我将执行数据库任务);

}



现在我的问题是...我的javascript函数返回true然后我的.cs页面函数也没有调用....



我尝试了什么:



现在我的问题是..我的javascript函数返回true然后我的.cs页面函数也没有调用....

解决方案

删除返回关键字



 <   asp:TextBox     ID   =  TextBox1    Onchange   =  here();    runat   =  server    AutoPostBack   =   True    OnTextChanged  < span class =code-keyword> =  TextBox1_TextChanged >  
< / asp:TextBox >


<script type="text/javascript">
  
  function here()  
  {
     return(confirm("YOU WANT"));  
  }
  
</script>


this is my text box ...

<asp:TextBox ID="TextBox1" Onchange="return here()" runat="server"
       AutoPostBack="True" ontextchanged="TextBox1_TextChanged">


and this is my cs code

protected void TextBox1_TextChanged(object sender, EventArgs e)
    {
        Response.Write("i will peroform data base task");
 
    }


now my problem is ... my javascript function returning true then also my .cs page function is not calling....

What I have tried:

now my problem is ... my javascript function returning true then also my .cs page function is not calling....

解决方案

remove the return keyword

<asp:TextBox ID="TextBox1" Onchange="here();" runat="server" AutoPostBack="True" OnTextChanged="TextBox1_TextChanged">
   </asp:TextBox>


这篇关于文本框客户端验证和服务器验证无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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