I am having a default.js file in shared folder. Dynamically we will send aspx file name and function name and the parameters to call corresponding aspx page and method.
Default.js method
function ValidateParams(fromdate,Id)
{
var exp=/^((((0?[13578])|(1[02]))[\/]((0?[1-9]|[0-2][0-9])|(3[01])))|(((0?[469])|(11))[\/]((0?[1-9]|[0-2][0-9])|(30)))|(0?[2][\/](0?[1-9]|[0-2][0-9])))[\/]\d{4}$/;
var exp1=/^(\d{9})$/;
if(exp.test(fromdate)&& exp1.test(Id))
{
CheckValidityofId("FormUI.CheckValidity",fromdate,Id)
}
}
function CheckValidityofId(lookupFunction,fromdate,Id) {
callback = function(response) {
if (response.error) {
alert(response.error);
}
else {
if (response.value =="NotAssociated")
{
document.getElementById(MessageID).innerText="Number is not associated";
}
else
{
document.getElementById(MessageID).innerText="This is NOT eligible";
}
}
}
if (fromdate.length > 0 && Id.length >0) {
eval(lookupFunction + "('" + fromdate + "','" + Id "'," + callback + ")");
}
return false;
}
Here is my FormUI.ascx.cs method
public partial class FormUI : UIView
{
public string CheckValidity(string FromDate, string Id)
{
// logic goes here
}
}
Please correct me what's the wrong why the above code is not working. Its not hitting the 'CheckValidity' method in ascx.cs file. Even I tried with the below code but its's also not working
$.getJSON("Form1003UI.ascx\CheckEligibility", {
Data: {
FromDate: fromdate,
Id: Id
}, }, function (data) {
// do stuff on callback
});
Please let me know what is missing.