VS2005中AJAX使用方法

来源:互联网 发布:知乎 祺贵人 编辑:程序博客网 时间:2024/05/01 03:44

VS2005中AJAX使用方法

//声明一个AJAX命名空间Ajax_showPL,在每个类定义之前加上此句。(注意:Web2.0不支持命名空间,他把所有的类都放在自己生成的App_Code文件夹中)

[AjaxPro.AjaxNamespace("Ajax_showPL")]

// HT_ShowPL_QT是一个类,在这个类中注册AJAX远程处理方法,把这句代码加在页面加载的事件中。这里用到了反射(反射是.NET中获取运行时类型信息的方式,让程序员可以在程序运行期获得程序集,模块,类的相关信息)

AjaxPro.Utility.RegisterTypeForAjax(typeof(HT_ShowPL_QT));

//声明AJAX方法,在每个AJAX方法前面加上此句代码。

[AjaxPro.AjaxMethod]

//同时,要在Web.config配置文件中做相应的修改。

<?xml version="1.0" encoding="gb2312" ?>

<!--

    注意: 除了手动编辑此文件以外,您还可以使用

    Web 管理工具来配置应用程序的设置。可以使用Visual Studio 中的

     “网站”->Asp.Net 配置”选项。

    设置和注释的完整列表在

    machine.config.comments 中,该文件通常位于

    /Windows/Microsoft.Net/Framework/v2.x/Config

-->

<configuration>

 

     <!--

  AJAX配置begin===================

  -->

     <configSections>

         <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>

     <ajaxNet>

         <ajaxSettings>

              <urlNamespaceMappings useAssemblyQualifiedName="false">

                   <!--

                       Set the attribute useAssemblyQualifiedName to true to enable

                       use of assemblies placed in the GAC by using the full assembly

                       qualified name.

                  

                       To hide internal knowledge of assemblies, classes and namespace

                       you can override the name of the virtual http endpoints.

                      

                       <add type="Namespace.Class1,Assembly" path="mypath" />

                   -->

              </urlNamespaceMappings>

              <jsonConverters>

                   <!--

                       This section can be used to add new IJavaScriptConverters to the

                       Ajax.NET Professional engine. If you want to disable built-in

                       converters you can use the remove tag.

                  

                       <remove type="Namespace.Class1,Assembly"/>

                       <add type="Namespace.Class2,Assembly"/>

                   -->

              </jsonConverters>

              <!--

                   Set the enabled attribute to true to get Stack, TargetSize and Source

                   information if an exception has been thrown.

              -->

              <debug enabled="true"/>

              <!--

                   This is the default configuration used with Ajax.NET Professional. You

                   can put there your static JavaScript files, or remove the path attribute

                   to completly disable the files.

             

                   <scriptReplacements>

                       <file name="core" path="~/ajaxpro/core.ashx" />

                       <file name="prototype" path="~/ajaxpro/prototype.ashx" />

                       <file name="converter" path="~/ajaxpro/converter.ashx" />

                   </scriptReplacements>

              -->

              <!-- <encryption cryptType="" keyType="" /> -->

              <!--

                   Set the enabled attribute to true to enable the use of an Ajax.NET Professional

                   token. This will send a token to the client that will be used to identify if the

                   requests comes from the same PC.

              -->

              <token enabled="false" sitePassword="password"/>

              <!--

                   The oldStyle section can be used to enable old styled JavaScript code or

                   functions that are not used any more.

             

                   <oldStyle>

                       <objectExtendPrototype/>

                       <appCodeQualifiedFullName/>

                   </oldStyle>

              -->

         </ajaxSettings>

     </ajaxNet>

 

     <!-- Handler configuration for Ajax.NET Professional -->

     <location path="ajaxpro">

         <system.web>

              <httpHandlers>

                   <add verb="*" path="*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/>

              </httpHandlers>

              <!--

                   If you need to have Ajax.NET Professional methods running on the

                   login page you may have to enable your own authorization configuration

                   here.

              -->

              <!--

              <authorization>

                   <deny users="?"/>

              </authorization>

              -->

         </system.web>

     </location>

 

     <!--

         If you are using Ajax.NET Professional with forms authentication you may need

         to allow ASP.NET to have access to following three files.

     -->

     <!--

     <location path="ajaxpro/prototype.ashx">

         <system.web>

              <authorization>

                   <allow users="*"/>

              </authorization>

         </system.web>

     </location>

 

     <location path="ajaxpro/core.ashx">

         <system.web>

              <authorization>

                   <allow users="*"/>

              </authorization>

         </system.web>

     </location>

 

     <location path="ajaxpro/converter.ashx">

         <system.web>

              <authorization>

                   <allow users="*"/>

              </authorization>

         </system.web>

     </location>

     -->

     <!--

  AJAX配置over===================

  -->

 

  <appSettings>

     <add key="ConnectString" value="server=100ZZ-1/SQLEXPRESS;database=my_wxfl;user id=bbbb;password=bbbb"/>

    <add key="open_Log" value="1"/> 

    <add key="local_url" value="F:/ceshiB/upfile/"/>

  </appSettings>

     <connectionStrings/>

     <system.web>

         <!--

            设置compilation debug="true" 将调试符号插入

            已编译的页面中。但由于这会

            影响性能,因此只在开发过程中将此值

            设置为true

        -->

         <compilation debug="true">

              <assemblies>

                   <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

                   <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>

                   <add assembly="System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>

              </assemblies>

         </compilation>

 

         <!--

            通过<authentication> 节可以配置ASP.NET 使用的

            安全身份验证模式,

            以标识传入的用户。

        -->

    <identity impersonate="true"/> <!--加用户权限-->

         <authentication mode="Windows"/>

         <!--

            如果在执行请求的过程中出现未处理的错误,

            则通过<customErrors> 节可以配置相应的处理步骤。具体说来,

            开发人员通过该节可以配置

            要显示的html 错误页

            以代替错误堆栈跟踪。

 

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">

            <error statusCode="403" redirect="NoAccess.htm" />

            <error statusCode="404" redirect="FileNotFound.htm" />

        </customErrors>

        -->

         <globalization requestEncoding="gb2312" responseEncoding="gb2312" />

         <roleManager enabled="true"/>

    <!--

        上传最大限制容量6M

    <httpRuntime executionTimeout="9000"

             maxRequestLength="709600"

             useFullyQualifiedRedirectUrl="false"

             minFreeThreads="8"

             minLocalRequestFreeThreads="4"

             appRequestQueueLimit="100"

             enableVersionHeader="true"/>

            

             -->

     </system.web 

     <!--=========== AJAX配置============ -->

</configuration>