来自sql server的asp.net中的Adrotator没有页面刷新 [英] Adrotator in asp.net from sql server without page refresh
本文介绍了来自sql server的asp.net中的Adrotator没有页面刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮我用Adrotator解决这个问题
i想为我的项目创建一个adrotator来显示存储在sql server中的广告..
i希望在不刷新页面的情况下显示广告..这就是我们的计时器..
i已经完成了这个..
但是没有工作......这是我第一次使用adrotate ...
please help me to correct this problem with Adrotator
i want to create an adrotator for my project to display the ads which is stored in sql server..
i want to display the ads without refreshing the page.. that is usin a timer..
i have done this..
but not working...its the first time im working with adrotate...
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
<asp:Timer ID="Timer1" runat="server" Interval="2000" ontick="Timer1_Tick1">
<asp:UpdatePanel ID="BannerPanel" runat="server" UpdateMode="Conditional">
<triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</triggers>
<contenttemplate>
<asp:AdRotator ID="AdRotator1" KeywordFilter="Asp.Net"
runat="server" Height="55px" Width="100px" />
</contenttemplate>
</div>
</form>
</body>
< b> .aspx
.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
public partial class ad_db : System.Web.UI.Page
{
SqlConnection con;
public void getcon()
{
con = new SqlConnection("Data Source=joker-pc;Initial Catalog=mytest;Integrated Security=True");
con.Open();
}
protected void Page_Load(object sender, EventArgs e)
{
getcon();
AdRotator1.DataSource = FetchAdsFromDB();
AdRotator1.DataBind();
}
private DataTable FetchAdsFromDB()
{
getcon();
string sql = "select photo1 from pic";
SqlDataAdapter da = new SqlDataAdapter(sql,con );
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
protected void Timer1_Tick1(object sender, EventArgs e)
{
AdRotator1.DataSource = FetchAdsFromDB();
AdRotator1.DataBind();
}
}
推荐答案
这篇关于来自sql server的asp.net中的Adrotator没有页面刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文