天天看點

VS2005中AJAX使用方法

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="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/"/>

    <add key="Shuiyin_img" value="F:/ceshiB/HT/img/logo.jpg"/>

    <add key="Shuiyin_font" value="www.100zz.com"/>

    <add key="http_url" value="http://192.168.1.101:8084/upfile/"/>

    <add key="Validate_bg" value="F:/WorkStation/rdxw/HT/img/Validate.JPG"/>

    <!--

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

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

    <add key="Shuiyin_img" value="F:/ceshiB/HT/img/logo.jpg"/>

    <add key="Shuiyin_font" value="www.100zz.com"/>

    <add key="http_url" value="http://192.168.1.101:8084/upfile/"/>

    <add key="Validate_bg" value="F:/ceshiB/HT/img/Validate.JPG"/>

    -->

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

繼續閱讀