Questions tagged [pagemethods]

Page Methods are functions in the code-behind file for an ASP.net WebForms page that can be invoked from Web Services or AJAX. They are decorated with the [WebMethod] attribute and marked with the static keyword (Shared in VB.NET).

A Page Method is a function in the code-behind file for an ASP.net WebForms page that can be invoked from Web Services or AJAX. They are somewhat similar to to JsonResult methods in ASP.net MVC.

Page Methods can be easily recognized by the presence of the [WebMethod] attribute and the static keyword (or Shared in VB.NET).

These methods can be used in Web Services or AJAX.

Since these are static / Shared method, they cannot refer to any instance data from the page. In particular, they cannot refer to the controls on the page.

In fact, since an instance of the page only exists during a HTTP request to the page, there is no instance available while the page method is running.

310 questions
45
votes
2 answers

WebMethod vs ScriptMethod

I have a .NET 3.5 aspx place with a method marked with the [WebMethod] attribute. I'm calling this with jQuery, sending JSON in both directions. This all works great. My question is, what does [ScriptMethod] do when applied to an method? I've tried…
Steve Johnson
37
votes
8 answers

Call ASP.NET PageMethod/WebMethod with jQuery - returns whole page

jQuery 1.3.2, ASP.NET 2.0. Making an AJAX call to a PageMethod (WebMethod) returns the full/whole page instead of just the response. A breakpoint on the page method shows it's never getting hit. I have the [WebMethod] attribute on my method, and…
Matt
  • 41,216
  • 30
  • 109
  • 147
32
votes
8 answers

Unknown web method. Parameter name: methodName

In researching this problem most SO issues were about the static method as a fix. Since it's not working with the real (and a bit sophisticated) WebMethod I've just created a simple one for the sake of checking if reaching the method itself is…
Daniel Sh.
  • 2,078
  • 5
  • 42
  • 67
24
votes
8 answers

calling an ascx page method using jquery

I know that I can call a page method with jquery using the following syntax $.ajax({ type: "POST", url: "Default.aspx/GetDate", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { //…
codette
  • 12,343
  • 9
  • 37
  • 38
23
votes
4 answers

PageMethods is not Defined in ASPX Page

I'm looking at some old code that I can only assume worked at one time. MyPage.aspx: function GetCompanyList(officeId) { var companyList = document.getElementById('<%= CompanyDropDown.ClientID %>'); if (companyList.length == 0) …
Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466
16
votes
8 answers

How to call page method with a parameter through in a javascript event?

I have method like this in my .cs : [System.Web.Services.WebMethod] public static void GetServiceInformation(IInfo x) //IInfo is an interface { x.l_power = true; x.lb_InboxCount = UserTrans.GetInbox(int.Parse(emp_num), 0); } Now i want to…
Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392
14
votes
1 answer

Pagemethods in asp.net

My Pagemethod implementation is not working in Chrome browser. I have ASP.NET 3.5 web application developed in VS 2008. The code below not working in chrome or Safari: function FetchDataOnTabChange(ucName) { PageMethods.FetchData(ucName,…
Chetan
  • 1,517
  • 3
  • 17
  • 25
14
votes
2 answers

ASP.NET page methods vs web service

I am building a dynamic partial load asp.net page, I would like to use jQuery to call page methods or web service to retrieve the content HTML. page methods or web service, performance wise, which way is better? If I call page method, on the server…
nandin
  • 2,549
  • 5
  • 23
  • 27
13
votes
5 answers

Pagemethods in popuppanel does not load the second time in IE9

I have a main page which has some pagemethod called to perform some activities. A popuppanel(popuppanel content page also have pagemethods) is used within this main page to show some details. If the same is executed multiple times (i.e., opening the…
RGA
  • 602
  • 2
  • 9
  • 39
9
votes
4 answers

Calling asp.net page method from javascript not working

Hi I am calling a simple page method from javascript , here is my code at markup function OnCallSumComplete(result, userContext, methodName) { alert(result); } function OnCallSumError(error, userContext, methodName) { …
windforceus
  • 193
  • 2
  • 4
  • 16
8
votes
2 answers

How to access page controls inside a static web method?

I have called a Code behind method using jQuery using a static WebMethod method. That web method call was success but when tried to access a text box control it is giving error. An object reference is required for the non-static field, method, or…
user5061957
7
votes
5 answers

Any way to do a synchronous PageMethods call?

I'm trying to do this: function DelBatch() {var userInfo = get_cookie("UserInfo"); PageMethods.DeleteBatchJSWM(userInfo, function(result) {window.location = "BatchOperations.aspx";}); } But it still runs…
user724198
7
votes
1 answer

Access ASP.NET control from static [WebMethod] (JS ajax call)

I have a ASP.NET WebSite and a custom control (lets call it myControl) on it. I need to call a method on this control with AJAX. I'm posting ajax call from JavaScript (jQuery) to C# WebMethod. This works fine, but I can't get to myControl in a…
Heko
  • 89
  • 1
  • 1
  • 9
7
votes
5 answers

PageMethods returning undefined result?

I have a very simple call to a PageMethod. When I step through my PageMethod in my .cs file, the value looks as expected. However, on the client side I get an undefined result. Any ideas? This should be horribly simple. Here is my js:…
Clay
  • 1,273
  • 2
  • 16
  • 23
6
votes
2 answers

Getting Exception Details from ASP.NET PageMethods on the Client SIde

I am having a pagemethod to which i give a call from my JavaScript say Pagemethods.MyMethod(MyParameter, onsucess, onfailure); In the Code behind, I have something like this: [WebMethod] public static void MyMethod(Param) { try{ …
SudheerKovalam
  • 628
  • 2
  • 7
  • 13
1
2 3
20 21