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

Async callback failing when page is posted back at the same time

I am facing problem with js async callback in my solution. Here is the req ; User clicks on 'Generate Excel' button. On server excel file is being generated with large amount of data (takes about 2 mins). During this time the user can do other…
Gaurav
  • 330
  • 7
  • 21
0
votes
1 answer

How to execute javascript returned from PageMethod

I have page, where I'm making an ajax call to PageMethod, and as a result I'm getting some html string, which I need to append to some div. Now Html string has some javascript code in it, so I expect this js code to execute, after I append html to…
Gev
  • 429
  • 6
  • 13
0
votes
1 answer

Move ASP.NET Page Methods Proxy from the page

I am using ASP.NET Page Methods for my application. Everything works like charm but I do not want my page methods generated inline in the page. Is there any way to move them to a WebResource.axd file or something similar. I don't really want to…
Stilgar
  • 22,354
  • 14
  • 64
  • 101
0
votes
2 answers

ASP.NET Forms: Using jquery to post to asp.net page method with parameters

I've seen lots of related questions, but nowhere have I found a simple example of code that passes parameters back to a page method via jquery. I've looked through some of the examples at encosia.com (thanks, Dave) but still haven't managed to get…
chris
  • 36,094
  • 53
  • 157
  • 237
0
votes
2 answers

Can't get webservice to recognize my parameters

It seems like this ought to be simple thing to do, but I can't invoke my web service call. Here is my code: var data = '{"deviceId":"e9b3f993-7ca1-442b-a5c2-001ab86e1af4","opid":202,"remarks":"fefawef"}'; $.ajax({ url: 'MyPage.aspx/MyMethod', …
Vivian River
  • 31,198
  • 62
  • 198
  • 313
0
votes
2 answers

Ajaxpro methods get global page variable to be reinitialized?

I have a problem with ajaxpro methods. In the .cs file I defined some global variable for my page, something like: public partial class Admin : System.Web.UI.Page { public int localidMember = 9; protected void Page_Load(object sender,…
user1507164
  • 81
  • 1
  • 4
0
votes
3 answers

Error while trying to get asp.net(C#) textbox text from ajax static WebMethod

I am using an ajax htmleditor in asp.net web application so i am trying to get the text the user has entered in the editor then i will send that text back to the client javascript function that will show the text in a div. But I am getting this…
user1306589
0
votes
2 answers

Passing jquery search results to a page method

I have am using a sortable jQuery list. I would like to send the results of that list to a webmethod for processing. So my javascript is something like: function ProcessSortableList() { var arr = {}; arr[0] = "item1"; arr[1] =…
Daniel
  • 16,026
  • 18
  • 65
  • 89
0
votes
2 answers

How to pass parameter from javascript to code behind?

i tried pass parameter from jscript to code behind, but it don't work. My code: [C#] [WebMethod] public static String sendEmail(String str) { ... msg.body = str; ... return str; } [jscript] If i use function alert, it return…
Trong Lam Phan
  • 2,292
  • 3
  • 24
  • 51
0
votes
1 answer

ASP.NET AJAX Page Methods Are Inconsistent

Given the following javascript code: function ValidateFlagAsUrgent() { selectedValuesList = document.getElementById('<%= _searchResultsUserControlUserControl.SelectedValuesHiddenFieldClientID %>').value; $.ajax({ …
Jim G.
  • 15,141
  • 22
  • 103
  • 166
0
votes
4 answers

Calling a Page Method when the Browser Closes

Hi here I'm trying to call a [webmethod] on bodyunload method. But it is getting fired on page load itself only. How do i prevent it? Here's the code I am using: [WebMethod] public static void AbandonSession() { …
Nagu
  • 4,954
  • 14
  • 52
  • 67
0
votes
4 answers

PageMethods in javascript as return of a function

javascript: var Enabled = false; function GateWay_Enabled(GateWay_Name) { PageMethods.GateWay_Enabled(GateWay_Name, onRequestComplete, onError); return Enabled; } …
SilverLight
  • 19,668
  • 65
  • 192
  • 300
0
votes
1 answer

Using setInterval with PageMethods

I am trying to call a LoadFile() function every X seconds using setInterval, and I want to call this in my document ready function , and a scriptmanager on my aspx page sets EnablePageMethods as true. But this doesnt seem to work and returns…
Diya
  • 3
  • 2
0
votes
1 answer

Is all the form data sent when using a Page Method?

I was under the impression that Page Methods and Script Methods created tiny AJAX requests (compared to PostBacks), but I'm inspecting an XHR of a Page Method call in Chrome's Developer Tools' Network tab, and seeing the entire form's data in the…
Protector one
  • 6,926
  • 5
  • 62
  • 86
0
votes
1 answer

string returned from page methods is html text, can not get return to display in the page

In my application I am able to use pagemethods to call server side functions from the client side. This works no problem. Where I am confused is with the return from the server side function. I am returning a string to the client side (html text)…
njj56
  • 611
  • 4
  • 19
  • 51
1 2 3
20
21