当前位置: 首页 > 图文教程 > 网络编程 > ASP > 用DataList控件开发一个简单的留言本程序

ASP
深入研究Application和Session对象(2)
深入研究Application和Session对象(3)
开始 .Net的旅程(一)
开始 .Net的旅程(二)
手把手教你使用VB来创建ASP组件(1)
手把手教你使用VB来创建ASP组件(2)
手把手教你使用VB来创建ASP组件(3)
手把手教你使用VB来创建ASP组件(4)
手把手教你使用VB来创建ASP组件(5)
手把手教你使用VB来创建ASP组件(6)
手把手教你使用VB来创建ASP组件(7)
手把手教你使用Java来编写ASP组件(1)
手把手教你使用Java来编写ASP组件(2)
手把手教你使用Java来编写ASP组件(3)
手把手教你使用Java来编写ASP组件(4)
手把手教你使用Java来编写ASP组件(5)
手把手教你使用Java来编写ASP组件(6)
ASP 3.0高级编程(二十四)
ASP 3.0高级编程(二十五)
ASP 3.0高级编程(二十六)

ASP 中的 用DataList控件开发一个简单的留言本程序


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 124 ::
收藏到网摘: n/a

  <%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.ADO" %>
<Html>
<Body BgColor="White">
<H3>DataList 控制元件<HR></H3>
<div id=Message runat=server></div>
<Form runat="server">
<table cellspacing=0 cellpadding=0 width="776" border=0>
  <tr>
    <td width="2%"><img height=20 src="/upload/tech/20091103/20091103102358_0537fb40a68c18da59a35c2bfe1ca554.gif"" width=16></td>
    <td width="98%" bgcolor=#333333 align="center"><font face=宋体 color=#ffffcc><b>留言本</b></font></td>
  </tr>
</table>
<asp:DataList id="DataList1" runat="server"
     Border="1" BorderColor="Black"
     CellPadding="2" CellSpacing="0"
     HeaderStyle-BackColor="#888888"
     ItemStyle-BackColor="#eeeeee"
     SelectedItemStyle-BackColor="#ffffff"
     HeaderTemplate-ColSpan="3"
     OnItemCommand="DataList_ItemCommand"
     Width="776">

<!--编号模版-->
<template name="HeaderTemplate" >
  <asp:LinkButton id="Tosay" runat="server" Text="我要发言"  ForeColor="#ffffff"/>
  <a href="temp.aspx"><font color="#ffffff">刷新界面</font></a>
  <asp:LinkButton id="Mange" runat="server" Text="管理留言"  ForeColor="#ffffff"/>
</template>


<!--内容模版-->
<template name="ItemTemplate">
<%# Container.DataItem("book_id")%>
<%# Container.DataItem("content")%>
<asp:LinkButton id="Detail" runat="server" Text="查看详细内容"  ForeColor="#333333"/>
</template>

<!--查看留言模版-->
<template name="SelectedItemTemplate">
  编号: <%# Container.DataItem("book_id")%><BR>
  发言人: <%# Container.DataItem("username")%><BR>
  时间: <%# Container.DataItem("post_time")%><BR>
  内容: <%# Container.DataItem("content")%><BR>
<div align="right"><asp:LinkButton id="Title" runat="server" Text="关闭" ForeColor="#333333"/></div>
</template>

</asp:DataList>
<table id="foot" cellspacing=0 cellpadding=0 width="776" border=0 runat="server" visible="false">
  <tr>
    <td bgcolor=#000000>
      <table cellspacing=1 cellpadding=3 width="100%"  border=0>
        <tr bgcolor=#ffffff>
          <td>大名:<Input Type="Text" id="Username" Size=20 runat="server" /><br>
留言:<Input Type="Text" id="Content" Size=20 runat="server"  />
<asp:LinkButton id="save" runat="server" Text="保存" OnClick="LinkButton1_Click"  AutoPostBack/><br>
<asp:LinkButton id="close" runat="server" Text="关闭"  OnClick="LinkButton2_Click"