my situation is like this thread :
ASP.NET Custom Validator + WebMethod + jQuery
my aspx codes :
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnablePageMethods="True">
<asp:TextBox ID="TextBox" runat="server" Width="170px" ValidationGroup="A" CssClass="txt"
TextMode="Password"></asp:TextBox>
<asp:CustomValidator ID="cvPass" runat="server" Display="Dynamic" ControlToValidate="TextBox"
ValidationGroup="A" ClientValidationFunction="CheckPass">
invalid
</asp:CustomValidator>
jquery:
function CheckPass(source, args) {
alert('asd');
$.ajax({
type: "POST",
async: false,
timeout: 500,
contentType: "application/json; charset=utf-8",
dataType: "json",
url: "Default.aspx/CheckPassword",
data: '{"Value":"' + args.Value + '"}',
success: function (result) {
alert('a');
args.IsValid = result.d;
}
});
}
code behind (c#):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using System.Web.Services;
using System.Web.Script.Services;
using System.Data;
using System.Text;
using System.Net.Mail;
namespace Nasim
{
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
[ScriptMethod]
public static bool CheckPassword(string pass)
{
return false;
}
}
}
as you see i want to check password using custom validator in ajax mode(using jquery).
but i do n't know why $.ajax does not work for me at all.
there is no error and nothing happens and always have postback.
should i add an specific library other that jquery?
i am using visual studio 2010 + .Net 4.
what is the problem and how can i fix it?
thanks in advance
alertfire? Are you including any other javascript libraries besides jquery? Have you looked at the response of the post in a tool like firebug?alert('asd')when I said alert. Just was confirming that your js function was actually getting called.