我做的一个自定义控件代码如下:
<%@ Control Language="C#" ClassName="showlr" %>
<%@ Import Namespace ="System.Data.OleDb" %>
<%@ Import Namespace ="System.Data" %>
<script runat="server">
private String HtmlCode(string TString)
{
if (TString != null)
{
TString = TString.Replace("\r", "<br>");
TString = TString.Replace(" ", " ");
TString = TString.Replace("[", "<img src=").Replace("]", ">");
return TString;
}
else
{
return TString = "无内容";
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
</script>
<table border="0" cellpadding="0" cellspacing="0" width="640" align="center" style="table-layout: fixed;WORD-BREAK: break-all; WORD-WRAP: break-word" >
<tr>
<%
string cs=Request["idh"].ToString();
string fdir = Server.MapPath("") + "\\App_Data\\wj.mdb";
string sqlstr = "select * from lr where id=" + cs;
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + fdir);
DataSet ds = new DataSet();
OleDbDataAdapter dr= new OleDbDataAdapter(sqlstr ,con);
dr.Fill(ds, "lr");
%>
<td bgcolor="#89b1dc" style="border-right: #cccccc thin solid; border-top: #cccccc thin solid;
border-left: #cccccc thin solid; border-bottom: #cccccc thin solid; text-align: center"
width="100%">
<%= ds.Tables[0].Rows[0][2].ToString() %></td>
</tr>
<tr>
<td width="100%" style="text-align: center">
作者:
<%= ds.Tables[0].Rows[0][3].ToString()%>
上传时间:<%= ds.Tables[0].Rows[0][5].ToString().Substring(0, ds.Tables[0].Rows[0][5].ToString().Length - 7)%>
</td>
</tr>
<tr>
<td width="640" align="left" valign="top" >
<hr color="#89b1dc" />
<%=HtmlCode(ds.Tables[0].Rows[0][4].ToString())%>
</td>
</tr>
</table>
我将红色标记部分放在<script>中,程序会告诉不认识ds,我只好像ASP一样混合着写,但这样写不好看,请问我要将红色部分放在<script>中怎样改写?