ASP.NET 4.0 New Feature : 表单控制项之延伸RepeatLayout功能

来源:互联网 发布:淘宝卖家被诈骗57000 编辑:程序博客网 时间:2024/06/03 13:50

 


文章来自: IT工程技术网 http://www.systhinker.com/html/36/n-11536.html

CheckBoxList 和RadioButtonList这两个清单控制项,在ASP.NET 4.0中的RepeatLayout属性有做了延伸性的功能加强,在以往的ASP.NET 3.5版本中,RepeatLayout属性只有两个选择可以设定,分别为: Table和Flow。

如果这个属性设定为RepeatLayout.Table,则清单中的项目会显示在资料表,如果这个属性设定为RepeatLayout.Flow,则清单中的项目不显示资料表结构。

例如假设我们把控制项设定为以下设定:

<asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatLayout="Flow">

<asp:ListItem Text="CheckBoxList" Value="cbl" />

</asp:CheckBoxList>

 

<asp:RadioButtonList runat="server" RepeatLayout="Table">

<asp:ListItem Text="RadioButtonList" Value="rbl" />

</asp:RadioButtonList>

那么浏览网页后所得到的HTML将分别转译为sapn和table为:

< span id="CheckBoxList1"> <input id="CheckBoxList1_0" type="checkbox" name="CheckBoxList1$0" />

<label for="CheckBoxList1_0">CheckBoxList</label>

</span>

 

< table id="RadioButtonList1" border="0">

<tr>

<td><input id="RadioButtonList1_0" type="radio" name="RadioButtonList1"

value="rbl" />

<label for="RadioButtonList1_0">RadioButtonList</label> </td>

</tr>

</table>

那么ASP.NET 4.0又多了另外两个选择设定,分别为:OrderedList 和UnorderedList,如果这个属性设定为RepeatLayout. OrderedList,则清单中的项目会显示使用ol搭配li设定显示,如果这个属性设定为RepeatLayout . UnorderedList,则清单中的项目会显示使用ul搭配li设定显示。

以下假设针对CheckBoxList分别设定RepeatLayout. OrderedList和RepeatLayout. UnorderedList,我们来看看所呈现不同的结果,首先当设定为OrderedList,则如下图所示,会有顺序性的排序编号资料:

如果是设定为UnorderedList,则会呈下如下图所示,并不会有顺序编号,但是会用条列重点方式:

这里要特别注意一点,假设你设定RepeatLayout为OrderedList 或是UnorderedList,那么另一个属性RepeatDirection就不能设定修改为Horizontal,否则将会出现设计上的错误,预设只能搭配Vertical。

文章来自: IT工程技术网 http://www.systhinker.com/html/36/n-11536.html

原创粉丝点击