2

I am trying to use page methods in my asp.net page. I have enable page methods set to true on the script manager, the webmethod attribute defined on the method, the function is public static string, I know the function works because when I run it from my code behind it generates the expected result, but when I call it via page method in my result function the result is always alerted as undefined. If I use fiddler it doesn't even look like there is additional traffic or a new request created. I'm running the site on port 82 if that makes a difference. I'm at a loss here. Can someone give me some pointers?

0

2 Answers 2

1

In your PagesMethods call, remove the parentheses from the callback and error functions:

PageMethods.getAdCodeInfo(value, onSuccess, onError)

onSuccess and onError are basically variables that point to the functions. So you don't need parentheses for variable names.

Sign up to request clarification or add additional context in comments.

Comments

0

OK, stupid me. Here is some code.

 function getName()
 {
    var ddlAdCodes=$get('<%=ddlAdCodes.ClientID %>');
    var value=ddlAdCodes.options[ddlAdCodes.selectedIndex].value;
    //alert(value);
    PageMethods.getAdCodeInfo(value,onSuccess(),onError());
 }

 function onSuccess(result)
 {
    alert(result);
 }

 function onError(error)
 {
    alert("error "+error);
 }

1 Comment

Next time hit the "Code Sample" button (101010) to format it nicely and make it easier to read.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.