Jquery验证消息在updatepanel中消失

时间:2010-10-25 19:16:26

标签: jquery updatepanel

我遇到的问题是,我在表单上有字段,其中包含我想要进行Jquery验证的更新面板。问题是当我单击确定按钮时,出现验证错误消息然后消失。看起来像一些回帖类型的问题,但想知道是否有人可以提供帮助。代码如下:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Project Management System</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.3.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.js"></script> 

</head>
<body>
<script type="text/javascript">
$(document).ready(function() {
$("#form1").validate({
rules: {
<%=txtFirstName.UniqueID %>: {
minlength: 5,
required: true
}

}, messages: {
<%=txtFirstName.UniqueID %>:{ 
required: "Please enter a valid username", 
minlength: "Username must be atleast 3 characters" 
} 
}
});
});
</script> 

<form id="form1" runat="server">
    <div id="wrapper">
        <div id="content">

        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>

        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" >

        <ContentTemplate>


                        <asp:Label ID="lbFirstName" runat="server" Text="FirstName"></asp:Label>

                         <asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>

                        <asp:Button ID="btAddEmployee" runat="server" Text="Add"/>


         </ContentTemplate>
    </asp:UpdatePanel> 



    </div> 
    </div>
</form>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,我只是在占位符上使用标签来更改asincpostback以执行回发,就像保存按钮一样

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <Triggers>
    <asp:PostBackTrigger ControlID="save buton id here" />  
    <asp:AsyncPostBackTrigger ControlID="go back button id here" />     
</Triggers>
<ContentTemplate>

 your content here
  <asp:Button ID="Button1" runat="server" Text="Button" />

</ContentTemplate>
</asp:UpdatePanel> 

所以,我有其他问题,在这种情况下,当它的跑回按钮错误menage apear,s但不要停止提交因为它asinc,我试图解决这个杀死方法当按下按钮时使用jquery die调用