Web 窗体简介[3]

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 ozx 的 blog

<asp:radiobuttonlist runat="server">
<asp:listitem text="choice1" value="1" selected="true"/>
<asp:listitem text="choice2" value="2"/>
</asp:radiobuttonlist >


表单提交和回传

下列控件用于将带有用户输入值的页面提交给服务器,以便用页面中的代码对这些值进行处理。这些控件会在服务器上产生一个 click 事件,供您在代码中使用。

button 控件可以生成一个能够将页面再提交给服务器的三维按钮:

<asp:button runat="server" text="click me"></asp:button>


linkbutton 控件的行为与 button 控件相同。但它在页面上会显示为一个超级链接:

<asp:linkbutton runat="server" text="click me"></asp:button>


imagebutton 控件也用于提交页面。它会显示为一幅图像,并且能够提供用户单击位置的 x 坐标和 y 坐标:

<asp:imagebutton runat="server" imageurl="net.gif"></asp:button>


导航

hyperlink 控件用于生成能够跳转到其它 url 的链接:

<asp:hyperlink runat="server" text="follow me" navigateurl="mypage.aspx"></asp:hyperlink>


图像显示

image 控件能够在页面上显示图像:

<asp:image runat="server" imageurl="net.gif"></asp:image>


版面控件

panel 控件常用作简单的组合控件以及动态创建的控件的容器。(请注意,panel 控件通常不具有可见的外观。)

<asp:panel runat="server"></asp:panel>

table 控件与相关的 tablerow 和 tablecell 控件相结合,可以用来以编程的方法创建表或表式版面布局:

<asp:table runat="server" gridlines="both" borderwidth="1px">
<asp:tablerow>
<asp:tablecell>[0,0]</asp:tablecell>
<asp:tablecell>[0,1]</asp:tablecell>
</asp:tablerow>
<asp:tablerow>
<asp:tablecell>[1,0]</asp:tablecell>
<asp:tablecell>[1,1]</asp:tablecell>
</asp:tablerow>
</asp:table>


日期选择

calendar 控件能够让用户浏览日期并进行日期选择(包括选择日期范围):

<asp:calendar runat=server daynameformat="firstletter" ...>
<property name=selecteddaystyle>
<asp:tableitemstyle font-bold="true" backcolor="#ccccff"/>
</property>
  ...
</asp:calendar>


列表绑定控件

列表绑定控件用于显示与其相关联的数据源或列表的内容。它们提供了创建多种自定义及标准版式的能力。本文结尾处的“有关的参考资料”一节中列出的一些文章将详细说明这些控件。

repeater 控件是一个简单的列表绑定控件,它使用模板(即用于设定版式的 html 代码片断)来以一种“朴实无华”的,即没有预定义外观的方式显示数据源的内容:

<asp:repeater runat="server">
<template name="headertemplate">
<ol>
</template>
<template name="itemtemplate">
<li>
<a runat="server" href='http://dev.csdn.net/article/8/<%# databinder.eval(container.dataitem, "siteurl") %>'>
<%# databinder.eval(container.dataitem, "sitename") %>
</a>
</li>
</template>
<template name="footertemplate">
</ol>
</template>
</asp:repeater>


datalist 控件也使用模板来显示与之绑定的数据源的内容。此外,它还提供了自定义外观格式和布局的功能:

<asp:datalist runat="server">
<template name="itemtemplate">
<%# databinder.eval(container.dataitem, "personname") %>
  ...
</template>
  ...
</asp:datalist>


datagrid 控件能够创建格式丰富的列表版式,用来显示与之绑定的数据源的内容。它提供了对排序、编辑和分页的支持。

<asp:datagrid runat="server" ...>
<property name="columns">
<asp:boundcolumn headertext="id" .../>
    ...
</property>
  ... 
</asp:datagrid>

本文关键:web
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top