1、代码中:
public partial class indexs : System.Web.UI.Page
{
Maticsoft.BLL.Advertise advertisebll = new Maticsoft.BLL.Advertise();
private static Maticsoft.Model.Advertise advertise = new Maticsoft.Model.Advertise();
protected void Page_Load(object sender, EventArgs e)
{
this.LitAdvertise1.Text = GetAdvertise1();//得到广告(形式文字)
this.LitAdvertise2.Text = GetAdvertise2();//得到广告(形式图片)
}
private string GetAdvertise1()
{
DataSet ds = advertisebll.GetList("");
string s = "";
int num = 0;
if (ds.Tables[0].Rows.Count > 20)
{
num = 20;
}
else
{
num = ds.Tables[0].Rows.Count;
}
for (int i = 0; i < num; i++)
{
string jobsort = ds.Tables[0].Rows[i]["displaytext"].ToString();//广告语
// s += "<div class=/"rencai/"><div class=/"t1/"><h4><a target=/"_blank/" href=/"AdvertiseDetail.aspx?id=" + ds.Tables[0].Rows[i]["id"].ToString() + "/">" + ds.Tables[0].Rows[i]["displaytext"].ToString() + "</a></h4></div></div>";
// s += "<div class=/"show_ad_text_wrap/" onmouseover= /"class= /'show_ad_text_bgcolor_change /'; /" onmouseout= /"class=/'show_ad_text_wrap/'; /"><div class=/"show_ad_text/"><a class=/"show_ad_text_black/" target=/"_blank/" href=/"AdvertiseDetail.aspx?id=" + ds.Tables[0].Rows[i]["id"].ToString() + "/">" + ds.Tables[0].Rows[i]["displaytext"].ToString() + "</a></div></div>";
s += "<div class=/"show_ad_text_wrap/"><div class=/"show_ad_text_black/"><a target=/"_blank/" href=/"AdvertiseDetail.aspx?id=" + ds.Tables[0].Rows[i]["id"].ToString() + "/">" + ds.Tables[0].Rows[i]["displaytext"].ToString() + "</a></div></div>";
}
ds.Tables[0].Dispose();
return s;
}
private string GetAdvertise2()
{
DataSet ds = advertisebll.GetList("");
string s = "";
int num = 0;
if (ds.Tables[0].Rows.Count > 20)
{
num = 20;
}
else
{
num = ds.Tables[0].Rows.Count;
}
for (int i = 0; i < num; i++)
{
s += "<div class=/"down/"><a href=/"AdvertiseDetail.aspx?id="+ ds.Tables[0].Rows[i]["id"].ToString() + "/"><img src="+ ds.Tables[0].Rows[i]["imagepath"].ToString() + " alt=/"/" /></a></div>";
}
ds.Tables[0].Dispose();
return s;
}
2、设计中
<div id="body_top_text_right">
<div class="literal">
<asp:Literal ID="LitAdvertise1" runat="server"></asp:Literal>
</div>
</div>
3、CSS设计
.show_ad_text_black a:link,.show_ad_text_black a:visited
{
color: #333333;
text-decoration: none;
}
.show_ad_text_black a:hover
{
background: #FF8C00;
display:block;
}