在asp.net Pagemethods [英] Pagemethods in asp.net
本文介绍了在asp.net Pagemethods的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我PageMethod的实现不是在Chrome浏览器的工作。
我有ASP.NET 3.5 Web应用程序在VS 2008中开发的。
在code低于Chrome或Safari不工作:
函数FetchDataOnTabChange(ucname创建)
{
PageMethods.FetchData(ucname创建,OnSuccessFetchDataOnTabChange,OnErrorFetchDataOnTabChange);
}功能OnErrorFetchDataOnTabChange(错误)
{
//做一点事
}功能OnSuccessFetchDataOnTabChange(结果)
{
//做一点事
}
解决方案
很抱歉的响应晚,但如果任何一个关于这个版本跌倒,应在所有浏览器中通过以下步骤工作。
- 页面方法必须具有
System.Web.Services.WebMethod
属性。 [的WebMethod] - 页面方法必须是公共的。
[的WebMethod]公共... - 页面方法必须是静态的。
[的WebMethod]公共静态... - 页面方法必须上定义
该页面(或内联或在
code-后面)。它不能被定义
在控制,母版页,或基
页。 - 的ASP.NET AJAX脚本经理必须
设置为true的EnablePageMethods。
这是从工作程序
aspx页面:
/ *脚本管理器还可以在一个母版页没有问题* /
< ASP:的ScriptManager ID =smMain=服务器的EnablePageMethods =真/>
<脚本类型=文/ JavaScript的>
功能GetDetails(ID){
PageMethods.GetDetails(doorId);
}
< / SCRIPT>
后面的 code:
[System.Web.Services.WebMethod]
公共静态无效GetDetails(字符串ID)
{}
祝你好运! : - )
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
}
解决方案
Sorry for the late response, but if any one stumbles on this later, 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 must be public. [WebMethod] public ...
- The page method must be static. [WebMethod] public static ...
- The page method must be defined on the page (either inline or in the code-behind). It cannot be defined in a control, master page, or base page.
- The ASP.NET AJAX Script Manager must have EnablePageMethods set to true.
This is from a working application
aspx page:
/* the script manager could also be in a master page with no issues */
<asp:ScriptManager ID="smMain" runat="server" EnablePageMethods="true" />
<script type="text/javascript">
function GetDetails(Id) {
PageMethods.GetDetails(doorId);
}
</script>
code behind:
[System.Web.Services.WebMethod]
public static void GetDetails(string Id)
{
}
Good luck! :-)
这篇关于在asp.net Pagemethods的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文