I know my question is very basic but somehow my code is not working.
I am trying to update a label value on textbox text change. Below is the sample of the javascript code which I am writing on my aspx page.
function UpdateDescription(ControlID) {//debugger;
ControlID = "ctl00_CP_" + ControlID;
UPCCode = document.getElementById(ControlID).value;
//alert(UPCCode);
$.ajax({ type: "POST",
url:"ProductPhotoRequisitions.aspx/GetUPCJSon",
//data: "{UPC:" + UPCCode + "}",
data: "UPC=" + UPCCode,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {alert(data.d);}
});
}
I am writing the webmethod in codebehind of the same page but somehow this function is not being called.
[WebMethod]
public string GetUPCJSon(String UPC)
{
//code to fetch label value
}
If your javascript is ok and if your only problem is the method not being called you should try and use this, the method should be static