📄 banner.ascx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Banner : System.Web.UI.UserControl
{
private string VirtualPath = "";
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds = new DataSet();
DAL.boBusiness bo = new DAL.boBusiness();
DAL.MakeConnection Conn = new DAL.MakeConnection();
DAL.clsDBConnkey ConnKey = new DAL.clsDBConnkey();
ConnKey = bo.loadkey();//得到config数据库连接
string sql = "Select Top 1 * from BlogStyle where ID=(select Top 1 BlogStyleId from myBlogStyle)";
try
{
if (sql != "")
{
ds = (DataSet)Conn.MakeConnectionMethod(sql, ConnKey, DAL.executeMethod.execute_DataSet, DAL.
EnumDBType.Sql, VirtualPath);
if (ds.Tables[0].Rows.Count > 0)
{
DataTable dt = ds.Tables[0];
for (int i = 0; i < dt.Rows.Count; i++)
{
for (int j = 0; j < dt.Columns.Count; j++)
{
if (dt.Rows[i][j] == null || dt.Rows[i][j].ToString() == "")
{
dt.Rows[i][j] = DBNull.Value;
}
}
this.Labbanner.Text = MakeHTML(dt.Rows[i]);
}
}
}
}
catch(System.Exception ex)
{
throw ex;
}
}
private string MakeHTML(DataRow dtRow)
{
string imageUrl = dtRow["BannerBackImage"].ToString();
if (imageUrl != "")
{
if(!System.IO.File.Exists(VirtualPath+imageUrl)) //如果不存在
{
imageUrl = "image/BannerImage.jpg";
}
}
string colorLift = dtRow["BannerBackColorLift"].ToString();
if (colorLift == "")
{
colorLift = "#CCCCCC";
}
string colorRight = dtRow["BannerBackColorRight"].ToString();
if(colorRight=="")
{
colorRight = "#99CC99";
}
string HTML = "";
HTML+= "<table width=780 border=0 align=center cellpadding=0 cellspacing=0>";
HTML += "<tr>";
HTML += "<td height=6 colspan=6 bgcolor=#c8c8c8></td>";
HTML += "</tr>";
HTML+= "<tr>";
HTML+= "<th width=168 height=28 bgcolor=#FFFFFF scope=col><img src=image/logo.gif width=154 height=28></th>";
HTML+= "<th colspan=5 bgcolor=#FFFFFF scope=col> </th>";
HTML+= "</tr>";
HTML+= "<tr valign=top>";
HTML += "<td height=139 colspan=6><img src=" + imageUrl+ " width=780 height=139></td>";
HTML += "</tr>";
HTML += "<tr>";
HTML += "<td height=18 bgcolor=" + colorLift + " ><font color=#FFFFFF><b><a href=Index.aspx>首页</a><b></font></td>";
HTML += "<td width=391 bgcolor=" + colorRight + "> </td>";
HTML += "<td width=58 align=center bgcolor=" + colorRight + ">登陆</td>";
HTML += "<td width=58 align=center bgcolor=" + colorRight + ">注册</td>";
HTML += "<td width=58 align=center bgcolor=" + colorRight + ">搜索</td>";
HTML += "<td width=61 align=center bgcolor=" + colorRight + ">帮助</td>";
HTML+= "</tr>";
HTML+= "</table>";
return HTML;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -