Kooboo CMS - Html.FrontHtml.Position 详解
DataContract
数据契约
http://www.cnblogs.com/Gavinzhao/archive/2010/06/01/1748736.html
https://msdn.microsoft.com/zh-cn/library/system.runtime.serialization.datacontractattribute.aspx
Html.FrontHtml.Position("main") 详解
1.首先我们打开工程文件,在搜索框里写上FrontHtml查找到FrontHtmlHelper类,如下图:

下面是关于Position的相关方法。
#region Position
public virtual IHtmlString Position(string positionID)
{
return Position(positionID, "");
} public virtual IHtmlString Position(string positionID, string defaultContent)
{
return Position(positionID, () => defaultContent);
}
public virtual IHtmlString Position(string positionID, Func<string> defaultContentFunc)
{
if (PageContext.PageRequestContext.RequestChannel == FrontRequestChannel.Design)
{
return new PageDesignHolder(this, positionID);
}
else
{
var positions = GetContentsForPosition(positionID);
if (positions.Length == )
{
defaultContentFunc = defaultContentFunc == null ? () => "" : defaultContentFunc;
return new HtmlString(defaultContentFunc());
}
else
{
var htmlStrings = RenderPositionContents(positions).ToArray();
return new AggregateHtmlString(htmlStrings);
} }
} public virtual IHtmlString Position(string positionID, bool requireMembershipAuthentication, params string[] membershipGroups)
{
if (PageContext.PageRequestContext.RequestChannel == FrontRequestChannel.Design)
{
return new PageDesignHolder(this, positionID);
}
else
{
if (requireMembershipAuthentication)
{
var permission = new PagePermission() { RequireMember = requireMembershipAuthentication, AllowGroups = membershipGroups };
if (!permission.Authorize(Html.ViewContext.HttpContext.Membership().GetMember()))
{
return new HtmlString("");
}
}
return Position(positionID);
}
}
下面来详细解释下。
一共有4个重载函数分别是:
public virtual IHtmlString Position(string positionID)
public virtual IHtmlString Position(string positionID, string defaultContent)
public virtual IHtmlString Position(string positionID, Func<string> defaultContentFunc)
public virtual IHtmlString Position(string positionID, bool requireMembershipAuthentication, params string[] membershipGroups)
这里如果有不明白的话可以,可以参考一下以下的知识:
1.positionID的意思就是你的HTML元素的ID。
2.如果对() => defaultContent)不理解的人,可以参看这里
3.对于Func<string>不理解的可以看这里
Kooboo CMS - Html.FrontHtml.Position 详解的更多相关文章
- Kooboo CMS - @Html.FrontHtml().Meta()详解。
下面是代码: public virtual IHtmlString Meta() { AggregateHtmlString htmlStrings = new AggregateHtmlString ...
- Kooboo CMS - @Html.FrontHtml().HtmlTitle() 详解
首先我们找到这个类. 这个类有如下的方法: #region Title & meta [Obsolete("Use HtmlTitle")] public IHtmlStr ...
- Kooboo CMS - Html.FrontHtml[Helper.cs] 各个方法详解
下面罗列了方法详解,每一个方法一篇文章. Kooboo CMS - @Html.FrontHtml().HtmlTitle() 详解 Kooboo CMS - Html.FrontHtml.Posit ...
- div+css定位position详解
div+css定位position详解 1.div+css中的定位position 最主要的两个属性:属性 absolute(绝对定位) relative(相对定位),有他们才造就了div+css布局 ...
- [TimLinux] CSS float和position详解
1.1. 定义 摘自w3school:float 属性定义元素在哪个方向浮动.以往这个属性总应用于图像,使文本围绕在图像周围,不过在 CSS 中,任何元素都可以浮动.浮动元素会生成一个块级框,而不论它 ...
- CSS定位属性Position详解
CSS中最常用的布局类属性,一个是Float(CSS浮动属性Float详解),另一个就是CSS定位属性Position. 1. position:static 所有元素的默认定位都是:position ...
- CSS中position详解与常见应用实现
在web前台开发时候,我们必不可少的会用到postion属性进行布局定位.今天总结了一下position知识点,与常用功能与大家分享,欢迎大家交流指正. 首先我们对postion属性进行详解. 在CS ...
- position详解
本文旨在普及一下position的用法,CSS中position的使用率相当之高,对于新入行的小白,不仅要知其然,还要知其所以然. position(定位类型),主要有4种属性值 : static.f ...
- CSS定位之position详解(转载)
本文转载于xingoo的博文:http://www.cnblogs.com/xing901022/p/5193751.html position属性 在前端中,position是很常见的属性.通过这 ...
随机推荐
- *HDU 1757 矩阵乘法
A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- Dexpress 中 grid的使用
grid 中加入checkbox Run desiger Columns ColumnEdit中选择checkbox 此时我们要在后台手动指定一个数据列如下代码: dtRebatesReport.Co ...
- js_截取Url值
"total" -->传递参数时的名字 var reg = new RegExp("(^|&)" + "total" + &q ...
- eclipse插件开发入门
2016-09-09 17:11:50 1. 概述 1.1 SWT/JFace 是Eclipse 的基础,Eclipse 的 Workbench 就是建立在 SWT/JFace 之上的.另外,JFac ...
- 利用sql注入
INSERT查询中实现注入攻击 1. 思路就是在含有insert语句的页面插入目标值信息.经常包含的是一个子查询. 2. 注意在insert过程中,左边的注入点和右边的注入点会有不同 3. 在mysq ...
- angularjs 自定义服务的三种方式
angularjs 中可通过三种($provider,$factory,$service)方式自定义服务,以下是不同的实现形式: // 定义module , module中注入$providevar ...
- Ajax全面基础学习(一)
快捷方法: $.get(url,[data],[callback],[type])get方法的[data]将被链在url后面[callback]是请求成功后的回调,可以得到响应数据,如果请求失败,看不 ...
- LINUX 下grep命令查找
当出现查找文件出现匹配到二进制文件时,大概是因为文件同时含有文本文件与二进制文件,需要加上 grep -a,就可以解决问题.
- [PHP源码阅读]strlen函数
文章来自:http://www.hoohack.me/2016/02/22/phps-source-analytics-strlen 我在github有对PHP源码更详细的注解.感兴趣的可以围观一下, ...
- 《Entity Framework 6 Recipes》中文翻译系列 (27) ------ 第五章 加载实体和导航属性之关联实体过滤、排序、执行聚合操作
翻译的初衷以及为什么选择<Entity Framework 6 Recipes>来学习,请看本系列开篇 5-9 关联实体过滤和排序 问题 你有一实体的实例,你想加载应用了过滤和排序的相关 ...