AjaxPro实现Ajax交互
2017-02-07 20:54:34 访问(2726) 赞(0) 踩(0)
相关下载:源码下载 AjaxPro.2.zip 单个Web的DEMO
-
// 关键代码 //
// aspx //
// slowxAjax是后台定义的一个变量 //
ajaxResult = slowxAjax.AjaxOKClick();
if (ajaxResult == null) {
return true;
}
document.getElementById("<%=this.txt_OutputValue.ClientID %>").value = ajaxResult.value;
// aspx.cs //
// 指定 slowxAjax //
[AjaxPro.AjaxNamespace("slowxAjax")]
public partial class _Default
// Page_Load里面注册方法 //
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(this.GetType());
}
// AjaxPro 方法实现 //
/// <summary>
///
/// </summary>
/// <returns></returns>
[AjaxPro.AjaxMethod]
public string AjaxOKClick
(
)
{
return "AjaxPro - DEMO:" + DateTime.Now.ToString();
}
// Web.Config //
<configSections>
<section name="FineUI" type="FineUI.ConfigSection, FineUI" requirePermission="false"/>
<sectionGroup name="ajaxNet">
<!--
If you are using Microsoft .NET 1.1 please remove the two attributes
requirePermission and restartOnExternalChanges, they are only supported
with .NET 2.0.
-->
<section name="ajaxSettings" type="AjaxPro.AjaxSettingsSectionHandler,AjaxPro.2" requirePermission="false" restartOnExternalChanges="true"/>
</sectionGroup>
</configSections>
<httpModules>
<add name="HttpCompressionModule" type="AjaxPro.HttpCompressionModule,AjaxPro.2"/>
</httpModules>
<httpHandlers>
<add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/>
</httpHandlers>
-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="WebForms_WebPages_AjaxPros_v1_Default"
ValidateRequest="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>AjaxPro.2的简单DEMO_<%=WebTitle %></title>
<script language="javascript" type="text/javascript" src="<%=strPhyPath %>/JS/jquery-1.8.2.min.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>AjaxPro.2的简单DEMO</h1>
<input type="button" id="btn_OK" value="确定" onclick="AjaxGetValue()" />
<asp:TextBox ID="txt_OutputValue" runat="server" Width="350px"></asp:TextBox>
</div>
</form>
</body>
</html>
<script language="javascript" type="text/javascript">
function AjaxGetValue() {
ajaxResult = slowxAjax.AjaxOKClick();
if (ajaxResult == null) {
return true;
}
document.getElementById("<%=this.txt_OutputValue.ClientID %>").value = ajaxResult.value;
}
</script>
-
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
[AjaxPro.AjaxNamespace("slowxAjax")]
public partial class WebForms_WebPages_AjaxPros_v1_Default
:
PageBase
{
/// <summary>
///
/// </summary>
/// <returns></returns>
[AjaxPro.AjaxMethod]
public string AjaxOKClick
(
)
{
return "AjaxPro - DEMO:" + DateTime.Now.ToString();
}
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(this.GetType());
}
}
-
<?xml version="1.0"?>
<!--
注意: 除了手动编辑此文件以外,您还可以使用
Web 管理工具来配置应用程序的设置。可以使用 Visual Studio 中的
“网站”->“Asp.Net 配置”选项。
设置和注释的完整列表在
machine.config.comments 中,该文件通常位于
\Windows\Microsoft.Net\Framework\v2.x\Config 中
-->
<configuration>
<configSections>
<section name="FineUI" type="FineUI.ConfigSection, FineUI" requirePermission="false"/>
<sectionGroup name="ajaxNet">
<!--
If you are using Microsoft .NET 1.1 please remove the two attributes
requirePermission and restartOnExternalChanges, they are only supported
with .NET 2.0.
-->
<section name="ajaxSettings" type="AjaxPro.AjaxSettingsSectionHandler,AjaxPro.2" requirePermission="false" restartOnExternalChanges="true"/>
</sectionGroup>
</configSections>
<appSettings/>
<connectionStrings/>
<system.web>
<!--
设置 compilation debug="true" 可将调试符号插入
已编译的页面中。但由于这会
影响性能,因此只在开发过程中将此值
设置为 true。
-->
<compilation debug="true"/>
<!--
通过 <authentication> 节可以配置 ASP.NET 用来
识别进入用户的
安全身份验证模式。
-->
<authentication mode="Windows"/>
<!--
如果在执行请求的过程中出现未处理的错误,
则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
开发人员通过该节可以配置
要显示的 html 错误页
以代替错误堆栈跟踪。
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
<httpModules>
<add name="HttpCompressionModule" type="AjaxPro.HttpCompressionModule,AjaxPro.2"/>
</httpModules>
<httpHandlers>
<add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/>
</httpHandlers>
</system.web>
</configuration>
标签:
AjaxPro实现Ajax交互 


上一条:
下一条:
相关评论
发表评论