Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET Javascript C#4.0 .NET4 , +
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.
 
Thanks
Prafulla
Posted 4-Apr-13 0:21am
Comments
Ankur\m/ at 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 at 14-Oct-13 12:53pm
   
post your code which you tried?
sri senthil kumar at 4-Apr-13 8:23am
   
Check this url for basic page method call syntax
http://witstuner.blogspot.in/2013/02/different-ways-of-ajax-call-in-asp.html
 
Also post your code so that we could help you...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

try this.. Smile | :)

Javascript

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

HTML
 
 
<span onclick="GetName()">Call Web Method</span>
 
C#
 
  [WebMethod]
        public static string GetData()
        {
            string name= "My name is Nirav Prabtani";
 
            return name;
        }
 
  Permalink  
Rate this: bad
good
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..!
  Permalink  

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

  Print Answers RSS
0 BillWoodruff 360
1 Mathew Soji 309
2 DamithSL 225
3 Afzaal Ahmad Zeeshan 202
4 Maciej Los 190
0 OriginalGriff 6,249
1 Sergey Alexandrovich Kryukov 5,853
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 3,865


Advertise | Privacy | Mobile
Web03 | 2.8.1411019.1 | Last Updated 30 May 2014
Copyright © CodeProject, 1999-2014
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