new.aspx
资源名称:Visual.rar [点击查看]
上传用户:yiyuerguo
上传日期:2014-09-27
资源大小:3781k
文件大小:3k
源码类别:
C#编程
开发平台:
Others
- <%@ Page Language="C#" Debug="true" %>
- <%@ Import Namespace="System.Data" %>
- <%@ Import Namespace="System.Data.OleDb" %>
- <html>
- <head>
- <title>宜都市网站首页新闻自动发布ASP.NET程序测试</title>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
- <style type="text/css">
- <!--
- A:link {text-decoration: none; font-size:9pt}
- A:visited {text-decoration: none; font-size:9pt}
- A:active {text-decoration: none; font-size:9pt}
- A:hover {text-decoration:line;color:red}
- body,table {font-size: 9pt}
- tr,td{font-size:9pt}
- -->
- </style>
- <script language="C#" runat=server>
- private void Page_Load(Object sender, EventArgs e)
- {
- if(!IsPostBack)
- {
- OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+ Server.MapPath("new.mdb"));
- OleDbDataAdapter myCommand = new OleDbDataAdapter("select top 12 * from aa order by shijian desc", myConnection);
- DataSet ds = new DataSet();
- myCommand.Fill(ds, "aa");
- MyList.DataSource = ds.Tables["aa"].DefaultView;
- MyList.DataBind();
- }
- }
- protected string FormatString(string str)
- {
- str=str.Replace(" "," ");
- str=str.Replace("<","<");
- str=str.Replace(">",">");
- str=str.Replace('n'.ToString(),"<br>");
- return str;
- }
- </script>
- <script language="javascript">
- function newwin(url)
- {
- var popup;
- url=url;
- popup=window.open(url,null,"top=5,left=5,width=600,resizable=yes,height=400,menubar=no,toolbar=no,scrollbars=yes,status=yes");
- popup.focus();
- }
- </script>
- <body bgcolor="#99CCFF" text="#000000" background="back.jpg">
- <form runat="server">
- <table width="450" border="0" align="center">
- <tr>
- <td width="608">
- <div align="center"><font color="#FF0000"><b><font color="#000000">网站首页新闻自动发布ASP.NET程序测试</font></b></font></div>
- </td>
- </tr>
- <tr>
- <td width="608"> </td>
- </tr>
- <tr>
- <td width="608">
- <div align="center"> <ASP:DataGrid id="MyList"
- runat="server"
- Width="400"
- GridLines="None"
- ShowFooter="false"
- CellPadding="2"
- CellSpacing="1"
- Font-Name="宋体"
- Font-Size="8pt"
- EnableViewState="false"
- AutoGenerateColumns="false"
- > <Columns> <asp:TemplateColumn> <ItemTemplate> <asp:HyperLink Text='<%# FormatString(DataBinder.Eval(Container.DataItem,"biaoti").ToString())%>' NavigateUrl='<%# "javascript:newwin("zhuan.aspx?id="+DataBinder.Eval(Container.DataItem,"id").ToString()+"");" %>' runat="server"/>
- <%# DataBinder.Eval(Container.DataItem, "shijian","{0:d}")%>
- </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid> </div>
- </td>
- </tr>
- <tr>
- <td width="608" height="13">
- <div align="right">>>> [ <a href="addnews.aspx" target="_parent">添加新闻</a>
- ] [ <a href="duo.aspx">更多新闻</a> ]</div>
- </td>
- </tr>
- </table>
- </form>
- </body>
- </html>