在线等待,谁能帮我这段asp.net代码分离出来。生成cs文件。立即给分

kellybs 2003-10-20 04:12:18
<%@Page Language="c#"%>
<%@ Register TagPrefix="UserControl" TagName="top" src="/top.ascx"%>
<%@ Register TagPrefix="UserControl" TagName="bottom" src="/bottom.ascx"%>
<%@Import Namespace="System.Data"%>
<%@Import Namespace="System.Data.SqlClient"%>
<script language="C#" runat="server">
void Page_Load()
{
int id=Convert.ToInt32(Request.QueryString["id"]);
string html="",memo="";

SqlConnection Conn=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
Conn.Open();
SqlCommand Cmd = new SqlCommand( "select subject,memo from changnews where id="+id+" order by id desc", Conn );
SqlDataReader dr = Cmd.ExecuteReader();

//判断是否显示记录

if ( dr.Read() )
{
memo=dr["memo"].ToString();
memo=memo.Replace(" "," ");

html+="<table width=560 border=0 align=center cellpadding=0 cellspacing=0>";
html+="<tr>";
html+="<td height=22 align=center class=bt>";
html+="<strong><font color=#CC0000>"+dr["subject"].ToString()+"</font></strong>";
html+="</td>";
html+="</tr>";
html+="<tr><td height=10></td></tr>";
html+="<tr><td height=22 class='li'>"+memo+"</td></tr>";
html+="<tr><td height=10></td></tr>";
html+="</table>";
}
divShow.Text=html;
dr.Close();
Conn.Close();

}
</script>
<html>
<head>
<title>欢迎你来到长三角网</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><UserControl:top id="top" runat="server"/></td>
</tr>
</table>
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<table width="560" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="22"><asp:label ID="divShow" runat="server"/></td>
</tr>
</table>

</td>
<td width="170" valign="top" bgcolor="#004684"><!--#include file="right.asp"--></td>
</tr>
</table>
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><UserControl:bottom id="bottom" runat="server"/></td>
</tr>
</table>
</body>
</html>
...全文
91 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
kellybs 2003-10-21
  • 打赏
  • 举报
回复
to:myadaidarling(FANCHEN)
Import Namespace="System.Data" ---> using System.Data;
这句是什么意思
myadaidarling 2003-10-20
  • 打赏
  • 举报
回复
Import Namespace="System.Data" ---> using System.Data;
foxballHLQ 2003-10-20
  • 打赏
  • 举报
回复
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

namespace test
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{


private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
int id=Convert.ToInt32(Request.QueryString["id"]);
string html="",memo="";
SqlConnection Conn=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
try
{
Conn.Open();
SqlCommand Cmd = new SqlCommand( "select subject,memo from changnews where id="+id+" order by id desc", Conn );
SqlDataReader dr = Cmd.ExecuteReader();
//判断是否显示记录
if ( dr.Read() )
{
memo=dr["memo"].ToString();
memo=memo.Replace(" "," ");
html+="<table width=560 border=0 align=center cellpadding=0 cellspacing=0>";
html+="<tr>";
html+="<td height=22 align=center class=bt>";
html+="<strong><font color=#CC0000>"+dr["subject"].ToString()+"</font></strong>";
html+="</td>";
html+="</tr>";
html+="<tr><td height=10></td></tr>";
html+="<tr><td height=22 class='li'>"+memo+"</td></tr>";
html+="<tr><td height=10></td></tr>";
html+="</table>";
}
divShow.Text=html;
}
catch(Exception ex)
{
}
finally
{
dr.Close();
Conn.Close();
}
}

#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{

this.Load += new System.EventHandler(this.Page_Load);

}
#endregion



}
}

62,041

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧