2010-10-25 74 views
0

我遇到了問題,其中包含更新面板的表單上的字段,我想對其執行Jquery驗證。問題是當我點擊確定按鈕,驗證錯誤信息出現然後消失。看起來像一些後回型問題,但想知道是否有人可以提供幫助。代碼如下: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> 
+0

jquery + updatepanels = - 毛 – Jason 2010-10-25 19:24:17

回答

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> 

如此,我有其他問題,在這種情況下,當它的運行返回按鈕的錯誤mepesage apear,s但不會停止提交,因爲它的asinc,即時試圖解決這個殺死方法當按鈕使用jquery時按下回撥