views:

29

answers:

1

Hey,

I am having an issue where i have fields on a form that contains an update panel that i want to do Jquery validation on. The issue is when i click the OK button, the validation error message appears then goes away. Looks like some post back type of issue but was wondering if someone could help. THe code is below:

<%@ 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"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head id="Head1" runat="server">
<title>Project Management System</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.3.js"&gt;&lt;/script&gt;
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.js"&gt;&lt;/script&gt; 

</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>
A: 

I have the same problem , i'm just using tag on place holder to change the asincpostback to do postback just like this for the save button

<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> 

so , i have other problem, on this case , when its run back button the error mensage apear,s but dont stop the submit because its asinc , im trying to resolve this killing the method when back button is pressed using jquery die call

Rafael Azevedo de Sena