CommunityServer布局 [转]

如何修改 CCS 的页面布局 相信很多人觉得比较麻烦
这里就来看看 CCS 的首页有些什么

1 、加载默认首页布局
<CS:ContentContainer runat="server" id="MPContainer">
文件位置: CommunityServerControls\ContentContainer.cs 该类继承于 MetaBuilders.WebControls.MasterPages.ContentContainer

用来加载 MasterPage( 主页布局 ) 的实体类
首先会访问当前设定的样式风格的 ( 主页控件 ) 默认为 Matser.ascx
如果不存在 ~ 则会进一步访问默认风格的主页控件 ~ 默认风格为 Default

在具体运行过程中。它首先去加载 ~/Themes/ 当前用户选择的风格名称 /Masters/Master.ascx
如果该文件不存在 ~ 则会跑去加载 ~/Themes/Default/Masters/Master.ascx
如果也不在 ~ 那就啥都不加载 ~
  所以当你设定某个风格后
你又不小心把这个风格的文件夹删除了或者这个风格除了文件夹啥都没有
首页依然还会有内容输出 ~ 正式因为他们默认加载的 ~/Themes/Default/Masters/Master.ascx
但是由于你当前风格不是 Default 所以仅能显示页面布局 而不懈怠 Default 的 CCS 样式控制
如果基于默认布局做新皮肤 ~ 可以新建一种风格的文件夹 然后仅仅添加需要的样式控制和图片就可以了

关于 <CS:ContentContainer runat="server" id="MPContainer"> 的内部
 public class Region : MetaBuilders.WebControls.MasterPages.Region{}
 public class Content : MetaBuilders.WebControls.MasterPages.Content{}
 public class Form : MetaBuilders.WebControls.MasterPages.NoBugForm {}
说明了 Region  Content  Form  均是继承 MetaBuilders 公司的 MasterPages 控件的部分
大家可以去 http://www.metabuilders.com/Tools/MasterPages.aspx 下载控件来做研究
该控件大致分为 4 个类
(1)Content: This control contains the content for a particular region
此类控件包含真实内容
(2)ContentContainer: This control serves two distincts purposes: - it marks the location where the Master Page will be inserted into the Page - it contains the various Content sections that will be matched to the Master Page's Region controls (based on their ID's).
此控件有两个意图 :
· 作为一个定位标志,标识 Master Page 将被插入到页中;
· 与 Region Controls 相匹配
(3)NoBugForm: A server form that does not cause a problem by being inside a master page or other naming container.
无错 form 。可以放心使用
(4)Region: The control marks a place holder for content in a master page
占位控件

2 加载文件和基本设置
3.1 加载 js 文件
<CS:Script Src = "Utility/UpdatePosts.js" runat = "server" />
文件位于: CommunityServerControls/Script .cs
文件继承于 LiteralControl 表示一个 html 元素
他会通过 Src 属性来定义 js 文件 并输出 <script src=\"{0}/{1}\" type=\"text/javascript\"></script> 这样的 js 引用 html 语句
如果 Src 属性为空 则默认加载 Utility/global.js 全局 js 文件

默认超链接方式设置
<cs:Base Target="_top" runat="server"/>
转换输出 <base target='_top'/>  这样的标签



3 加载自定义的皮肤控件

有不少包含了皮肤功能的控件均继承于
SecureTemplatedWebControl 或者 TemplatedWebControl.cs 两个控件
SecureTemplatedWebControl 继承于 TemplatedWebControl 而 TemplatedWebControl 又继承于 WebControl, INamingContainer
TemplatedWebControl 控件会通过 SkinName 属性加载当前风格下的皮肤如果不存在则会加载默认布局的皮肤文件
SecureTemplatedWebControl 除了具备 TemplatedWebControl 的功能外还有检验当前 url 的功能用来判断当前访问是否一个基于本站的访问
在每个皮肤控件对应的类中我们可以通过重构 CreateChildControls 方法对该控件进行初始化的设置重构 AttachChildControls 方法
来对皮肤上的控件对应的变量事件进行设定
比如首页上的 <CS:Login SkinName="Skin-LoginSmall.ascx" runat="server" />
会去加载 Skin-LoginSmall.ascx 的布局
在 CommunityServerControls\Login.cs 里面我们可以看到该控件的代码

转载于:https://www.cnblogs.com/guodapeng/archive/2007/12/21/1009039.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值