五月综合缴情婷婷六月,色94色欧美sute亚洲线路二,日韩制服国产精品一区,色噜噜一区二区三区,香港三级午夜理伦三级三

您現(xiàn)在的位置: 365建站網(wǎng) > 365文章 > ExtAspNet應(yīng)用技巧(十四) - 系統(tǒng)設(shè)置

ExtAspNet應(yīng)用技巧(十四) - 系統(tǒng)設(shè)置

文章來(lái)源:365jz.com     點(diǎn)擊數(shù):465    更新時(shí)間:2009-09-17 10:27   參與評(píng)論

界面截圖



數(shù)據(jù)庫(kù)表(X_Config)


設(shè)計(jì)視圖: 


數(shù)據(jù): 



幫助類

因?yàn)榇伺渲眯畔槿止蚕?,所以我們用一個(gè)幫助類在整個(gè)應(yīng)用程序生命周期只加載一次:
    namespace AppBox
    {
        public class XConfigHelper
        {
            #region fields & constructor

            /// <summary>
            /// 緩存在內(nèi)存
            /// </summary>
            private static XConfigCollection configs = new XConfigCollection();
            /// <summary>
            /// 載入所有的配置項(xiàng)
            /// </summary>
            static XConfigHelper()
            {
                ReloadColl();
            }
            /// <summary>
            /// 重新加載所有的配置項(xiàng)
            /// </summary>
            public static void ReloadColl()
            {
                configs = new Select().From<XConfig>()
                    .ExecuteAsCollection<XConfigCollection>();
            }
            #endregion
            #region methods
            /// <summary>
            /// 獲取配置信息
            /// </summary>
            /// <param name="key"></param>
            /// <returns></returns>
            public static string GetValue(string key)
            {
                foreach (XConfig config in configs)
                {
                    if (config.ConfigKey == key)
                    {
                        return config.ConfigValue;
                    }
                }
                return String.Empty;
            }
            /// <summary>
            /// 設(shè)置值
            /// </summary>
            /// <param name="key"></param>
            /// <param name="value"></param>
            public static void SetValue(string key, string value)
            {
                foreach (XConfig config in configs)
                {
                    if (config.ConfigKey == key)
                    {
                        config.ConfigValue = value;
                    }
                }
            }
            /// <summary>
            /// 保存所有更改的配置項(xiàng)
            /// </summary>
            public static void SaveAll()
            {
                configs.SaveAll();
            }
            #endregion
            #region properties
            /// <summary>
            /// 網(wǎng)站標(biāo)題
            /// </summary>
            public static string Title
            {
                get
                {
                    return GetValue("Title");
                }
                set
                {
                    SetValue("Title", value);
                }
            }
            /// <summary>
            /// 列表每頁(yè)顯示的個(gè)數(shù)
            /// </summary>
            public static int PageSize
            {
                get
                {
                    return Convert.ToInt32(GetValue("PageSize"));
                }
                set
                {
                    SetValue("PageSize", value.ToString());
                }
            }
            /// <summary>
            /// 菜單樣式(手風(fēng)琴式,樹(shù)型菜單)
            /// </summary>
            public static string MenuType
            {
                get
                {
                    return GetValue("MenuType");
                }
                set
                {
                    SetValue("MenuType", value);
                }
            }

            #endregion
        }
    }
    


ASPX標(biāo)簽

    <ext:PageManager ID="PageManager1" AutoSizePanelID="SimpleForm1" runat="server" />
    <ext:SimpleForm ID="SimpleForm1" runat="server" LabelWidth="100px" BodyPadding="5px"
        EnableBackgroundColor="true" ShowBorder="false" Title="系統(tǒng)設(shè)置">
        <Items>
            <ext:TextBox ID="tbxTitle" runat="server" Label="網(wǎng)站標(biāo)題" Required="true" ShowRedStar="true">
            </ext:TextBox>
            <ext:NumberBox ID="nbxPageSize" runat="server" Label="表格顯示項(xiàng)數(shù)" Required="true" ShowRedStar="true">
            </ext:NumberBox>
            <ext:DropDownList ID="ddlMenuType" Label="菜單樣式" runat="server" Required="true" ShowRedStar="true">
                <ext:ListItem Text="手風(fēng)琴式" Value="accordion" />
                <ext:ListItem Text="樹(shù)型菜單" Value="tree" />
            </ext:DropDownList>
            <ext:Button ID="btnSave" runat="server" ValidateForms="SimpleForm1" Text="保存設(shè)置" OnClick="btnSave_OnClick">
            </ext:Button>
        </Items>
    </ext:SimpleForm>
    


這里面有一些需要注意的屬性:
  • PageManager的屬性AutoSizePanelID="SimpleForm1",指定SimpleForm1充滿整個(gè)頁(yè)面
  • SimpleForm1的屬性ShowBorder="false",去掉藍(lán)色的邊框(因?yàn)檫@個(gè)SimpleForm是以IFrame的形式嵌入另一個(gè)頁(yè)面的)
  • SimpleForm1的屬性EnableBackgroundColor="true",藍(lán)色的背景色
  • tbxTitle的屬性Required="true"和ShowRedStar="true",指定必填項(xiàng)和紅色的標(biāo)記
  • btnSave的屬性ValidateForms="SimpleForm1",點(diǎn)擊此按鈕需要驗(yàn)證的表單(可以指定多個(gè)表單,以逗號(hào)分隔)



后臺(tái)代碼

    public partial class config : PageBase
    {
        private static readonly log4net.ILog logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        #region Page_Load
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData();
            }
        }
        private void LoadData()
        {
            tbxTitle.Text = XConfigHelper.Title;
            nbxPageSize.Text = XConfigHelper.PageSize.ToString();
            ddlMenuType.SelectedValue = XConfigHelper.MenuType.ToLower();
        }
        #endregion
        #region Events
        protected void btnSave_OnClick(object sender, EventArgs e)
        {
            XConfigHelper.Title = tbxTitle.Text.Trim();
            XConfigHelper.PageSize = Convert.ToInt32(nbxPageSize.Text.Trim());
            XConfigHelper.MenuType = ddlMenuType.SelectedValue.ToLower();
            XConfigHelper.SaveAll();
            // 刷新父頁(yè)面
            ExtAspNet.PageContext.RegisterStartupScript("parent.window.location.href=parent.window.location.href;");
        }
        #endregion
    }
    


注意:在保存屬性之后,我們需要刷新父頁(yè)面來(lái)應(yīng)用更改。ExtAspNet.PageContext.RegisterStartupScript用來(lái)向頁(yè)面注冊(cè)一段腳本,這是一個(gè)常用的函數(shù)。


下一章,我們會(huì)根據(jù)這里設(shè)置的菜單類型(樹(shù)形菜單或者手風(fēng)琴式菜單),來(lái)在左側(cè)的區(qū)域內(nèi)動(dòng)態(tài)創(chuàng)建菜單。




下載全部源代碼


如對(duì)本文有疑問(wèn),請(qǐng)?zhí)峤坏浇涣髡搲?,廣大熱心網(wǎng)友會(huì)為你解答?。?點(diǎn)擊進(jìn)入論壇

發(fā)表評(píng)論 (465人查看,0條評(píng)論)
請(qǐng)自覺(jué)遵守互聯(lián)網(wǎng)相關(guān)的政策法規(guī),嚴(yán)禁發(fā)布色情、暴力、反動(dòng)的言論。
昵稱:
最新評(píng)論
------分隔線----------------------------

其它欄目

· 建站教程
· 365學(xué)習(xí)

業(yè)務(wù)咨詢

· 技術(shù)支持
· 服務(wù)時(shí)間:9:00-18:00
365建站網(wǎng)二維碼

Powered by 365建站網(wǎng) RSS地圖 HTML地圖

copyright © 2013-2024 版權(quán)所有 鄂ICP備17013400號(hào)