欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

asp.net Coolite 学习交流

程序员文章站 2024-03-11 18:03:07
coolite toolkit 简介 coolite toolkit 是一个支持asp.net ajax的web控件。 coolite toolkit是基于跨浏览器的ext...

coolite toolkit
简介
coolite toolkit 是一个支持asp.net ajax的web控件。
coolite toolkit是基于跨浏览器的
extjs 库开发而来的,并且简化了开发步骤,并且包含有丰富的ajax运用。
coolite toolkit和extjs 都是开源的。
官方主页:

下载地址:
samples:


而且我在cnblogs 建立了小组,用cnblogs的可以去加入:   (csdn 管理员不要踢我  -  。-!)


另外最近我加入了讨论coolite的q群:86399374


先给那些没有用过extjs 或 coolite 的朋友打一下预防针-- 很多人都知道extjs控件又大又慢,但因为它界面美观,ajax+json操作简单方便,因此作为企业应用还是不错的选择。而coolite基于extjs,因此无可避免也是继承这个缺点(我现在用的0.7版本的dll有6m多)。但是用了coolite,你就可以省掉一大串那样管理的js代码了,界面完全可以用它来简单配置就得到很cool的效果,js只是作为少量的客户端操作。


coolite最大不足是:还是开发阶段,bug不少。


废话少说,给你一个简单的ajax例子,你就明白为什么我喜欢它了:


1. ajaxevet:

//这是一个服务端方法

  protected void updatetimestamp(object sender, ajaxeventargs e)
{
this.settime();
}

//html 调用上述方法
<ext:button id="button1" runat="server" text="click me">
<ajaxevents>
<click onevent="updatetimestamp">
<eventmask showmask="true" mindelay="500" msg="updating timestamp..." />
</click>
</ajaxevents>
</ext:button>

onevent="updatetimestamp" 就是指点击按钮后调用服务端方法updatetimestamp 来更新某个标签的时间

2. ajaxmethod:

<script runat="server">
[ajaxmethod]
public void settimestamp()
{
this.label1.text = string.concat("server time: ", datetime.now.tolongtimestring());
}
</script>

<ext:button id="button5" runat="server" text="click me" icon="lightning">
<listeners>
<click handler="coolite.ajaxmethods.settimestamp();" />
</listeners>
</ext:button>

第一次用coolite的人基本都会漏掉配置这一至关重要的环节。

如果想开启ajax事件,请记得在web.config 里做以下配置:


    <httphandlers>
      <add path="*/coolite.axd" verb="*" type="coolite.ext.web.resourcemanager" validate="false"/>      
    </httphandlers>


    <httpmodules>     
      <add name="ajaxrequestmodule" type="coolite.ext.web.ajaxrequestmodule, coolite.ext.web"/>
    </httpmodules>


    <modules>
      <!--coolite config-->
      <add name="ajaxrequestmodule" precondition="managedhandler" type="coolite.ext.web.ajaxrequestmodule, coolite.ext.web"/>
    </modules>


   <handlers>
      <!--coolite config-->
      <add name="ajaxrequesthandler" verb="*" path="*/coolite.axd" precondition="integratedmode" type="coolite.ext.web.resourcemanager"/>
    </handlers>


官方关于配置的详细说明文件:


   
--------------------------------------------------------------------------
                         sample web.config
--------------------------------------------------------------------------

<?xml version="1.0"?>
<configuration>
  <configsections>
    <section name="coolite" type="coolite.web.ui.globalconfig" requirepermission="false" />
  </configsections>

  <!-- 
      coolite global configuration properties

      ajaxeventurl : string
          the url to request for all ajaxevents.
          default is "".

      ajaxmethodproxy : clientproxy
          specifies whether server-side methods marked with the [ajaxmethod] attribute will output configuration script to the client.
          if false, the ajaxmethods can still be called, but the method proxies are not automatically generated.
          specifies ajax method proxies creation. the default value is to create the proxy for each ajax method.
          default is 'default'. options include [default|include|ignore]

      ajaxviewstatemode : viewstatemode
          specifies whether the viewstate should be returned and updated on the client during an ajaxevent.
          the default value is to exclude the viewstate from the response.
          default is 'default'. options include [default|exclude|include]

      cleanresourceurl : boolean
          the coolite controls can clean up the autogenerate webresource url so they look presentable.       
          default is 'true'. options include [true|false]

      clientinitajaxmethods : boolean
          specifies whether server-side methods marked with the [ajaxmethod] attribute will output configuration script to the client.
          if false, the ajaxmethods can still be called, but the method proxies are not automatically generated.
          default is 'false'. options include [true|false]

      gzip : boolean
          whether to automatically render scripts with gzip compression.       
          only works when renderscripts="embedded" and/or renderstyles="embedded".      
          default is true. options include [true|false]

      scriptadapter : string
          gets or sets the current script adapter.    
          default is "ext". options include [ext|jquery|prototype|yui]

      renderscripts : resourcelocationtype
          whether to have the coolite controls output the required javascript includes or not.      
          gives developer option of manually including required <script> files.       
          default is embedded. options include [embedded|file|none]

      renderstyles : resourcelocationtype
          whether to have the coolite controls output the required stylesheet includes or not.      
          gives developer option of manually including required <link> or <style> files.      
          default is embedded. options include [embedded|file|none]

      resourcepath : string
          gets the prefix of the url path to the base ~/coolite/ folder containing the resources files for this project.
          the path can be absolute or relative.

      scriptmode : scriptmode
          whether to include the release (condensed) or debug (with inline documentation) ext javascript files.      
          default is "release". options include [release|debug]

      sourceformatting : boolean
          specifies whether the scripts rendered to the page should be formatted. 'true' = formatting, 'false' = minified/compressed.
          default is 'false'. options include [true|false]

      stateprovider : stateprovider
          gets or sets the current script adapter.
          default is 'postback'. options include [postback|cookie|none]

      theme : theme
          which embedded theme to use.      
          default is "default". options include [default|gray|slate]

      quicktips : boolean
          specifies whether to render the quicktips. provides attractive and customizable tooltips for any element.
          default is 'true'. options include [true|false]
  -->

  <coolite theme="default" />

 
  <!--
      the following system.web section is only requited for running asp.net ajax under internet
      information services 6.0 (or earlier).  this section is not necessary for iis 7.0 or later.
  -->
  <system.web>
      <httphandlers>
      <add path="*/coolite.axd" verb="*" type="coolite.ext.web.resourcemanager" validate="false" />
    </httphandlers>
      <httpmodules>
          <add name="ajaxrequestmodule" type="coolite.ext.web.ajaxrequestmodule, coolite.ext.web" />
      </httpmodules>
  </system.web>

 
    <!--
      the system.webserver section is required for running asp.net ajax under internet information services 7.0.
      it is not necessary for previous version of iis.
  -->
    <system.webserver>
        <validation validateintegratedmodeconfiguration="false"/>
        <modules>
            <add name="ajaxrequestmodule" precondition="managedhandler" type="coolite.ext.web.ajaxrequestmodule, coolite.ext.web" />
        </modules>
        <handlers>
            <add name="ajaxrequesthandler" verb="*" path="*/coolite.axd" precondition="integratedmode" type="coolite.ext.web.resourcemanager"/>
        </handlers>
    </system.webserver>
</configuration>