WEB开发网
开发学院网页设计JavaScript ExtJs 备忘录(1)—— Form表单(上) [ 控件使用... 阅读

ExtJs 备忘录(1)—— Form表单(上) [ 控件使用 ]

 2009-09-07 00:00:00 来源:WEB开发网   
核心提示: 这个PageBase类主要做以下三个工作:a).权限判断这里权限判断是空的,大家实际项目中可以加上或者与现在项目进行集成,ExtJs 备忘录(1)—— Form表单(上) [ 控件使用 ](2),b).ExtJS必须的资源文件加载在OnInit页面的HtmlHead中按顺序加载ext-all.c

这个PageBase类主要做以下三个工作:

a).  权限判断

这里权限判断是空的,大家实际项目中可以加上或者与现在项目进行集成。

b).  ExtJS必须的资源文件加载

在OnInit页面的HtmlHead中按顺序加载ext-all.css、ext-base.js、ext-all.js、ext-lang-zh_CN.js

c).  路由请求

处理Ext的GET/POST请求,模拟服务器端控件的事件。

小技巧:

Request.QueryString["method"]中method参数名称是忽略大小写的。

2.2  ExtHelper.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Web.UI.HtmlControls;

namespace ExtJS.Ext
{
    public sealed class ExtHelper
    {
        #region MemberVariable

        public static readonly string EXT_BASE = ConfigurationManager.AppSettings["EXT_BASE"] ?? "/js/ext";
        /// <summary>
        /// ext-all.css
        /// </summary>
        public static readonly string EXT_CSS_ALL = EXT_BASE + "/resources/css/ext-all.css";
        /// <summary>
        /// ext-all.js
        /// </summary>
        public static readonly string EXT_JS_ALL = EXT_BASE + "/ext-all.js";
        /// <summary>
        /// ext-base.js
        /// </summary>
        public static readonly string EXT_JS_BASE = EXT_BASE + "/adapter/ext/ext-base.js";
        /// <summary>
        /// ext-lang-zh_CN.js
        /// </summary>
        public static readonly string EXT_JS_LANGUAGE = EXT_BASE + "/source/locale/ext-lang-zh_CN.js";
        /// <summary>
        /// EasyExt.js
        /// </summary>
        public static readonly string EXT_JS_EASYEXT = EXT_BASE + "/plugins/EasyExt.js";

        /// <summary>
        ///  0    ext-all.css
        ///  1    ext-base.js
        ///  2    ext-all.js
        ///  3    ext-lang-zh_CN.js
        ///  4    EasyExt.js
        /// </summary>
        private static readonly IList<HtmlGenericControl> extresource;

        #endregion

        #region Constructors

        static ExtHelper()
        {
            extresource = new List<HtmlGenericControl>();

            //ext-all.css
            HtmlGenericControl css_ext_all = new HtmlGenericControl("link");
            css_ext_all.Attributes.Add("type", "text/css");
            css_ext_all.Attributes.Add("rel", "stylesheet");
            css_ext_all.Attributes.Add("href", EXT_CSS_ALL);
            extresource.Add(css_ext_all);

            //ext-base.js
            HtmlGenericControl js_ext_base = new HtmlGenericControl("script");
            js_ext_base.Attributes.Add("type", "text/javascript");
            js_ext_base.Attributes.Add("src", EXT_JS_BASE);
            extresource.Add(js_ext_base);

            //ext-all.js
            HtmlGenericControl js_ext_all = new HtmlGenericControl("script");
            js_ext_all.Attributes.Add("type", "text/javascript");
            js_ext_all.Attributes.Add("src", EXT_JS_ALL);
            extresource.Add(js_ext_all);

            //ext-lang-zh_CN.js
            HtmlGenericControl js_ext_lang = new HtmlGenericControl("script");
            js_ext_lang.Attributes.Add("type", "text/javascript");
            js_ext_lang.Attributes.Add("src", EXT_JS_LANGUAGE);
            extresource.Add(js_ext_lang);

            //EasyExt.js
            HtmlGenericControl js_ext_easyext = new HtmlGenericControl("script");
            js_ext_easyext.Attributes.Add("type", "text/javascript");
            js_ext_easyext.Attributes.Add("src", EXT_JS_EASYEXT);
            extresource.Add(js_ext_easyext);

        }

        #endregion

        #region Method

        /// <summary>
        /// 添加Ext资源文件
        /// </summary>
        /// <param name="head"></param>
        /// <param name="page"></param>
        public static void Add(HtmlHead head, System.Web.UI.Page page)
        {
            if (head != null)
            {
                if (extresource != null)
                {
                    //head.Controls[0]为title
                    head.Controls.AddAt(1, extresource[0]);
                    head.Controls.AddAt(2, extresource[1]);
                    head.Controls.AddAt(3, extresource[2]);
                    head.Controls.AddAt(4, extresource[3]);
                   // head.Controls.AddAt(5, extresource[4]);
                }
            }
        }

        #endregion
    }
}

编缉推荐阅读以下文章

  • 暂无相关文章

Tags:ExtJs 备忘录 Form

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接