Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
JavaScript
function Validation()
{
    var txtDob = document.getElementById("<%=txtDob.ClientID%>").value;
    var returnVal = "true";
    if (txtDob != "") {
        if (isDate(txtDob) == false)
            $("#<%=txtDob.ClientID%>").addClass("txtValidate");
        else
            $("#<%=txtDob.ClientID%>").removeClass("txtValidate");
    }
    if (returnVal == "true")
        return true;
    else
        return false;
}

if the above javascript function returns true only then my server code will execute ....
HTML
<asp:TextBox ID="txtDob" runat="server" AutoPostBack="true" onchange="rerurn Validation();"  OnTextChanged="txtExample_TextChanged"></asp:TextBox>

Code Behind
C#
protected void txtExample_TextChanged(object sender, EventArgs e)
 {
      // If the client side function returns true then only this will execute..
 }
Posted
Updated 25-Jun-13 21:51pm
v4
Comments
Gregory Gadow 25-Jun-13 9:14am    
I'm not sure what is your question.
bbirajdar 25-Jun-13 9:32am    
And the question is ?
sjelen 25-Jun-13 10:19am    
If you don't want postback just set AutoPostBack="false"

1 solution

Hello Sumant,

In your Javascript you are not updating the value of variable returnvalue. So your function is always returning true resulting in a postback.

Regards,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900