Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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...

ASP.NET
<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>


.aspx

C#
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();
    }   
}
Posted
Updated 12-Mar-14 5:57am
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900