Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Adrotator in asp.net from sql server without page refresh

$
0
0

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:ScriptManager>
        <asp:Timer ID="Timer1" runat="server" Interval="2000" ontick="Timer1_Tick1">
       </asp:Timer>
       <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>
      </asp:UpdatePanel>
    </div>
    </form>
</body>

.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; publicpartialclass ad_db : System.Web.UI.Page
{
    SqlConnection con;publicvoid getcon()
    {
        con = new SqlConnection("Data Source=joker-pc;Initial Catalog=mytest;Integrated Security=True");
        con.Open();
    }protectedvoid 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;      
    }    protectedvoid Timer1_Tick1(object sender, EventArgs e)
    {        
        AdRotator1.DataSource = FetchAdsFromDB();
        AdRotator1.DataBind();
    }   
}

Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>