ajax如何调用页面方法 RT,除了调用WEBSERVICE,还可以调用页面方法,具体怎么做?给个例子 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 前提在asp.net ajax 框架下 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title> <script type="text/javascript"> function btnInvoke_onclick() { var theName = $get("helloName").value; PageMethods.SayHelloFromPage(theName, onSayHelloSucceeded); } function onSayHelloSucceeded(result) { $get("result").innerHTML = result; } </script></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server" /> <input id="helloName" type="text" /> <input id="btnInvoke" type="button" value="Test" onclick="return btnInvoke_onclick()" /> <div id="result"></div> </form></body></html>[WebMethod] public static string SayHelloFromPage(string name) { return string.Format("Hello {0}!", name); } TO LS:不知道你是否真的实现了,你连<Services> <asp:ServiceReference Path="yourpage.aspx" /></Services>都 没添加,那么你前台是怎么调用的页面方法? 我现在的问题是“PageMethods在前台未定义”还需要添加什么引用? ASPxGridView控件 获取行? 【注意,注意!】 关于百度文库的编程思路及方法flash,PDF/DOC在线阅读器 FileUpload????? (菜鸟提问)怎么使用webserver里面的方法? 在datalist中进行图片地址数据的绑定,我想修改图片地址,该怎么做呢 欢迎加入群 asp.net+c# 群号是:7199731 Ajax 有两个问题 关于VB脚本无法运行的问题? 谁用过国外的上传大文件的示例啊?(急,在线等) 使用xmlhttp出现的错误???? 简单SQL2000语句 不同 的界面间如何传递内容
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function btnInvoke_onclick() {
var theName = $get("helloName").value;
PageMethods.SayHelloFromPage(theName, onSayHelloSucceeded);
}
function onSayHelloSucceeded(result) {
$get("result").innerHTML = result;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server" />
<input id="helloName" type="text" />
<input id="btnInvoke" type="button" value="Test"
onclick="return btnInvoke_onclick()" />
<div id="result"></div>
</form>
</body>
</html>
[WebMethod]
public static string SayHelloFromPage(string name)
{
return string.Format("Hello {0}!", name);
}
<Services>
<asp:ServiceReference Path="yourpage.aspx" />
</Services>
都 没添加,那么你前台是怎么调用的页面方法?
还需要添加什么引用?