当前位置: 代码迷 >> ASP.NET >> 旧话重提,怎么在Command_Click前用JS检测检测是否为空?为空,则不执行
  详细解决方案

旧话重提,怎么在Command_Click前用JS检测检测是否为空?为空,则不执行

热度:7078   发布时间:2013-02-25 00:00:00.0
旧话重提,如何在Command_Click前用JS检测检测是否为空?为空,则不执行。
如上题。

------解决方案--------------------------------------------------------
为你的button加上onclick事件

<input id= "txtValue " type= "text " />
<asp:button id= "btnSubmit " Text= "Submit "
OnClientClick= "if (document.getElementById( 'txtValue ').value != ' ') return true; else return false; " />
------解决方案--------------------------------------------------------
UseSubmitBehavior = "false "
------解决方案--------------------------------------------------------
OnClientClick= "if (document.getElementById( 'txtValue ').value != ' ') return true; else return false; "
------------------

function check()
{
if (document.getElementById( 'txtValue ').value != ' ') return true; else return false;
}
OnClientClick= "return check() "