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
4
votes
1 answer

Globally handling exceptions in static aspx [WebMethods] in ASP.NET

The default behavior of a [WebMethod] attributed static method on an aspx page is to return the error to the caller. We are accessing these methods using json, and the only way we have found of capturing exceptions is either a try/catch in every…
Jake Hall
  • 1,963
  • 22
  • 24
4
votes
2 answers

Alternate way to use page method inside user control asp.net

Is there a way by which i can achieve functionality of page method inside a user control. Any help is appreciated, Thanks :)
mehul9595
  • 1,925
  • 7
  • 32
  • 55
4
votes
2 answers

Async functions in C# deadlock when called from javascript aspx page via PageMethods

Problem Summary: I'm trying to use PageMethods to call a C# function from an HTML page. The problem is that the C# function I'm calling is marked as async and will await the completion of other functions. When the nested async C# functions are…
4
votes
4 answers

Returning complex types (multiple Lists) to client side using jquery.ajax

I'm designing a page which makes an ajax call (via jQuery.ajax) to a page method on the server side. On the server side, I have two classes: Agent and Channel. In the page method, I'd like to return a List and a List to the client…
Kamyar
  • 18,639
  • 9
  • 97
  • 171
4
votes
2 answers

PageMethod and URl Rewrite

I am having issue with my pagemethod + url rewrite. When using regular URL: http://myweb.com/mypages/abc.aspx call to the PageMethod works fine. But when i use a friendly URL : http://myweb.com/abc it does work. No error though. Any help would be…
Murali Bala
  • 1,133
  • 2
  • 18
  • 28
4
votes
3 answers

Exporting HTML Table to Excel via Page Method

I have the following code on the client side for retrieving data from the HTML Table and then send it to the server through the page method: function dtExportToCSV(dataTable) { var elements = dtDataToJSON(dataTable); var headers =…
Eder
  • 1,874
  • 17
  • 34
4
votes
2 answers

Framework Similar to ASP.Net AjaxPro

Currently, I'm using AjaxPro Framework (http://www.ajaxpro.info/) to call any methods in my web application from the client side. But users have some serious problems using it. (e.g success callbacks don't work in Chrome. More info about the…
Kamyar
  • 18,639
  • 9
  • 97
  • 171
4
votes
4 answers

PAGEMETHODS is not working from JS function

I am trying to call code behind method from JS function using pagemethods but its not calling and its not throwing any error either... function example(){ pagemethods.method(); } **aspx.cs [webmethod] public static void method(){ //some…
user3212507
  • 173
  • 2
  • 3
  • 11
4
votes
2 answers

WebMethod not called (triggered) by PageMethod in Visual Studio 2013

I have the following problem: The call from a WebMethod is not being done on a project created in Visual Studio 2013 (ASP.NET WebForms Application). If I create a project, for example, in Visual Studio 2008 and migrate to VS 2013 works correctly.…
4
votes
8 answers

request.querystring not found in static method

I have static method in which I want to extract querystring value of the request. But it gives me null value when i am calling it from webmethod. Below is the some code public static int GetLatestAssetId() { int itemid=0; if…
Rajaram Shelar
  • 7,537
  • 24
  • 66
  • 107
4
votes
3 answers

returning value from page method in asp.net

I have a page method which is doing some complicated validation on server side. I have a button to validate. javascript code is below: function resultOfValidation(result); { return result; } function IsValidDate() { …
Sanjay Gupta
  • 186
  • 2
  • 11
4
votes
2 answers

Session state blocking async ajax call from processed concurrently

I am trying to make 6 asynchronous jQuery ajax calls to my .NET Page Method all at once on document.ready to request for different sets of data from the database and in return render as charts to users. Problem is that when one chart takes a long…
user1487182
  • 117
  • 1
  • 8
3
votes
4 answers

Using PageMethods with jQuery

Simply put I want to call public static methods decorated with WebMethod attribute inside my code-behind C# file from jquery.ajax to get some json and other simple stuff (in different functions). But instead I'm getting whole page :'( I'm not using…
TheVillageIdiot
  • 40,053
  • 20
  • 133
  • 188
3
votes
3 answers

Pass Array of JavaScript objects to PageMethod

Here's the situation: I would like to iterate through a table with input controls, collect up the values and then submit them to an ASP.NET PageMethod to save the data to the database. I have the collection all figured out but am getting an error…
Jared
  • 7,165
  • 6
  • 49
  • 52
3
votes
1 answer

PageMethod 404 only on deployed website under XP/IIS 5.1. What security settings should I be aware of?

Been trouble-shooting this for a few days now and have basically run dry of leads. Here's the code: [WebMethod] public static bool EnableEditMode() { bool successful = false; try { GlobalSettings globalSettings =…
Sean Anderson
  • 27,963
  • 30
  • 126
  • 237
1 2
3
20 21