日期:2014-05-18  浏览次数:20424 次

在点击Button时依据页面状态来判断是否回送(postback)?
比如页面上有些控件的内容(比如Textbox1)要通过Button1单击来回送,问题是如果Textbox1的内容为空,那么就调用javascript在页面上说明Textbox1内容不能为空,放弃回送,否则就回送。请问这怎么实现啊?

------解决方案--------------------
JS
function Confirm()
{
if(docunment.getElementById( "textbox1 ").value= " ")
{
windows.alert( '请输入 ');
return false;
}
}
html:
<asp:button id= "Button1 " runat= "server " Text= " 提 交 " OnClientClick= "return Confirm(); "> </asp:button>
------解决方案--------------------
笔误,没有环境,下面的应该可以
JS:
function Confirm() 

if(document.getElementById( "textbox1 ").value= "") 

windows.alert( '请输入 ');
return false; 


html: 
<asp:button id= "Button1 " runat= "server " Text= " 提 交 " OnClientClick= "return Confirm(); "> </asp:button>