Click here to Skip to main content
11,932,048 members (57,969 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET Javascript .NET C#4.0 , +
I am using PageMethods to call server side method from client side but I am getting a problem that server side method is calling only if, I am calling the method from source part, if i am making a javascript file with the same javascript code and adding the link into the page then it is not working, only PageMthods is not working but all other thing of javascript file is working fine.

Please suggest how would I resolve this issue.

Posted 4-Apr-13 0:21am
Ankur\m/ 4-Apr-13 5:26am
My first guess would be - the URL isn't correct. Can you show your javascript code which is calling the pagemethod?
JoCodes 14-Oct-13 12:53pm
post your code which you tried?
sri senthil kumar 4-Apr-13 8:23am
Check this url for basic page method call syntax

Also post your code so that we could help you...
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

try this.. Smile | :)


function GetName() {
        type: "POST",
        url: "Default.aspx/GetData", //Pagename/Functionname
        contentType: "application/json;charset=utf-8",
        data: {},//data
        dataType: "json",
        success: function (data) {
        error: function (result) {


<span onclick="GetName()">Call Web Method</span>


      public static string GetData()
          string name= "My name is Nirav Prabtani";
          return name;
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

Hi Friend,

It should not affect weather keeping script in page level or in script file.
Check once weather you gave right file or any other syntax.

it is good to find the error with Firebug..!

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.151126.1 | Last Updated 30 May 2014
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100