如何输入框失去焦点自动postback? 谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 onmouseout="javascript:postback();"<script language="javascript"> function poatback() { form1.submit(); }</script> onblur="javascript:postback();" <script language="javascript"> function poatback() { form1.submit(); } </script> 你也可以玩玩这个。就是当用户在文本框里输入的东西后焦点离开时调用Web Service,如果满足条件就在Label上显示√,否则×。//TestService.asmx[System.Web.Script.Services.ScriptService]public class TestService : System.Web.Services.WebService { public TestService () { //如果使用设计的组件,请取消注释以下行 //InitializeComponent(); } [WebMethod] public bool CheckValid(string str) { return str == "test"; //如果用户输入的字符串等于test返回true,否则返回false; } }<head runat="server"> <title>无标题页</title> <script type="text/javascript"> function callWebService(val) { TestService.CheckValid(val, OnSuccess); } function OnSuccess(result) { $get('<%= Label1.ClientID %>').innerText = result==true ? "√" : "×"; } </script></head><form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> <Services> <asp:ServiceReference Path="~/TestService.asmx" /> </Services> </asp:ScriptManager> <div> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Label ID="Label1" runat="server" Text=""></asp:Label>protected void Page_Load(object sender, EventArgs e){ TextBox1.Attributes["onblur"] = "callWebService(this.value);";} 截取字符串的问题!!! datagrid模板列小数问题 如何在客户端脚本中调用asp.net validation服务器控件来校验录入结果? 寻求刷新触发事件的最佳解决方案 ASP.NET使用history.back()返回上一页的问题 如何设置session的超时时间! 这一行怎么变成Jquery asp.net 中怎么嵌入视频 在datagrid裡我要按item排序為什麼不行,要如何做? 循环为数组赋值 如何用RegularExpressionValidator防止SQL注入? 动态生成表格的时候第一例如果是合并,怎么作?
function poatback()
{
form1.submit();
}
</script>
function poatback()
{
form1.submit();
}
</script>
public class TestService : System.Web.Services.WebService { public TestService () { //如果使用设计的组件,请取消注释以下行
//InitializeComponent();
} [WebMethod]
public bool CheckValid(string str) {
return str == "test"; //如果用户输入的字符串等于test返回true,否则返回false;
}
}<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function callWebService(val)
{
TestService.CheckValid(val, OnSuccess);
}
function OnSuccess(result)
{
$get('<%= Label1.ClientID %>').innerText = result==true ? "√" : "×";
}
</script>
</head>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="~/TestService.asmx" />
</Services>
</asp:ScriptManager>
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Attributes["onblur"] = "callWebService(this.value);";
}