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是很常见的属性.通过这 ...
随机推荐
- 【noip 2016】 蚯蚓(50分)(earthworm)
50分小程序,写了2天- 题目在这里 一个单调队列,写的都是p=0的点,考试的时候要是弄到这些分的话--不说了-- 羡慕AC的神犇啊,54行的满分程序,而我-- #include <iostre ...
- asp.net 验证码(一)Session
1.模板页 //创建网页模板 输入验证码文本框 并且将文本框中的内容发送的后端验证中去 <p>请输入验证码:<input type="text" name=&qu ...
- mysql添加一个用户
对于添加mysql的远程访问用户,一定要记得刷新刷新系统权限表不然你怎么弄都是不成功的. insert into mysql.user(Host,User,Password) values(" ...
- ql 判断 函数 存储过程是否存在的方法
下面为您介绍sql下用了判断各种资源是否存在的代码,需要的朋友可以参考下,希望对您学习sql的函数及数据库能够有所帮助. 库是否存在 if exists(select * from master..s ...
- JSP学习笔记
JSP学习笔记 Jsp网页主要分为Elements与Template Data两部分. Template Data:JSP Container不处理的部分,例如HTML内容 Elements:必须经由 ...
- Tomcat搭建
标签:Tomcat 概述 Tomcat 服务器是一个免费的开放源代码的Web 应用服务器,属于轻量级应用服务器,在中小型系统和并发访问用户不是很多的场合下被普遍使用,是开发和调试JSP 程序的首选. ...
- 开始研究web,mark一下
之前想要搞引擎,经过思考之后,定位为webgl方面的引擎,这个决定早就做了,只是没有写下来 做了一些调研之后,确定使用babylon.js 和typescript 和c# 来开发 Babylo ...
- [New Portal]Windows Azure Storage (14) 使用Azure Blob的PutBlock方法,实现文件的分块、离线上传
<Windows Azure Platform 系列文章目录> 相关内容 Windows Azure Platform (二十二) Windows Azure Storage Servic ...
- Constraint2:constraint
一,Constraint 是表定义的一部分,用于实现数据完整性. Data Integrity 由三种类型的constraint实现: Entity Integrity:数据是唯一的.约束: prim ...
- 针对格式文件,Python读取一定大小的文件内容
由数据库导出的数据是格式化数据,如下所示,每两个<REC>之间的数据是一个记录的所有字段数据,如<TITLE>.<ABSTRACT>.<SUBJECT_COD ...