pagemethods

How to get controls in static web method

谁都会走 提交于 2019-11-27 19:42:10
问题 I have a [WebMethod] and i want to assign values to a text box using the this code: [WebMethod] public static void MyMethod(string s) { //TextBox1.Text = s; //Here how can i access the textbx? } 回答1: You can't. The whole point of [WebMethod] s is that they don't run the ASP.Net page lifecycle. This way, they're fast and parallelizable. Your controls don't exist. Instead, you should use Javascript (better) or an UpdatePanel (worse). 回答2: in case of static method(ie, page method asynchronous

calling an ascx page method using jquery

点点圈 提交于 2019-11-27 08:36:31
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) { // Replace the div's content with the page method's return. $("#Result").text(msg.d); } }); This works for aspx pages but is it possible with ascx pages? (web controls) I've been trying it for about half an hour and since I can't get it to work I'm wondering if it's even possible. Note: Just to be clear, when I try to call the ascx page I am updating the url in

PageMethod and URl Rewrite

 ̄綄美尐妖づ 提交于 2019-11-27 06:27:05
问题 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 much appreciated. 回答1: You can set the right path to the aspx file from javascript using the PageMethods.set_path method: <script type="text/javascript"> PageMethods.set_path("/mypages/abc.aspx"); </script> The answer is taken from the official asp

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

纵然是瞬间 提交于 2019-11-27 05:28:26
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 static WebMethod. Any ideas how to solve this problem? Short version: AJAX call from JS to C# WebMethod works -> * here (in this method) I need to call a method on my custom control which is inaccessible because of static method type * [WebMethod] public static List<CustomListControl.IListItem> GetListItems() { // CAN'T GET TO MY CONTROL - need to return

Pagemethods in asp.net

人走茶凉 提交于 2019-11-27 05:07:07
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, OnSuccessFetchDataOnTabChange, OnErrorFetchDataOnTabChange); } function OnErrorFetchDataOnTabChange(error) { //Do something } function OnSuccessFetchDataOnTabChange(result) { //Do something } hardba11 This should work in all browsers by following the steps below: The page method must have the System.Web.Services.WebMethod attribute. [WebMethod] The page method

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

不打扰是莪最后的温柔 提交于 2019-11-26 18:37:32
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 it is public static, returns string and accepts no params. I even tried adding [ScriptService] at the top of my class to see if it helped, but it did not. I have seen this post Jquery AJAX with ASP.NET WebMethod Returning Entire Page which had my same symptoms, but I am still having a problem. I read http://encosia.com/2008/05/29/using-jquery-to

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

时光怂恿深爱的人放手 提交于 2019-11-26 17:33:51
问题 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 static WebMethod. Any ideas how to solve this problem? Short version: AJAX call from JS to C# WebMethod works -> * here (in this method) I need to call a method on my custom control which is inaccessible because of static method type * [WebMethod]

calling an ascx page method using jquery

一笑奈何 提交于 2019-11-26 14:12:38
问题 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) { // Replace the div's content with the page method's return. $("#Result").text(msg.d); } }); This works for aspx pages but is it possible with ascx pages? (web controls) I've been trying it for about half an hour and since I can't get it to work I'm wondering if it's

How to access page controls inside a static web method? [duplicate]

こ雲淡風輕ζ 提交于 2019-11-26 09:55:16
问题 This question already has answers here : Access ASP.NET control from static [WebMethod] (JS ajax call) (1 answer) How to get controls in static web method (2 answers) Closed last year . 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 property. [WebMethod] public static Savedata() { //code to