AdRotator ASP Control - How to rotate advertisements on Web Page?
C# - AdRotator Control in ASP.NET To Rotate Advertisements Ads Without Refreshing The Page
AdRotator control is a Rich Web Server Control and It is used to randomly display advertisements in an asp.net website. In this post I will explain how do we use AdRotator Control to make rotating ads without refreshing the page. Find the source code below :-
Default.aspx
<%@ Page Language="C#"
AutoEventWireup="true"
CodeFile="Default.aspx.cs"
Inherits="_Default"
%>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Adrotator
- Rotate advertisements on Web Page with AJAX</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<p>
Sample ..</p>
<asp:Timer ID="Timer1" Interval="1500" runat="server" />
<asp:UpdatePanel ID="up1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:AdRotator ID="AdRotator1" AdvertisementFile="~/App_Data/Ads.xml" KeywordFilter="small"
runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
Using jQuery
Default.aspx
<%@ Page Language="C#"
AutoEventWireup="true"
CodeFile="Default.aspx.cs"
Inherits="_Default"
%>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Adrotator
- Rotate advertisements on Web Page using jQuery</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function () {
setInterval(function () {
$("#adr").load(location.href
+ " #adr", "" + Math.random() + "");
}, 2000);
});
</script>
</head>
<body>
<form id="form1" runat="server">
<p>
Sample ..</p>
<div class="ads">
<asp:AdRotator ID="adr" AdvertisementFile="~/App_Data/Ads.xml" KeywordFilter="small"
runat="server" />
</div>
</form>
</body>
AdRotator ASP Control - How to rotate advertisements on Web Page?
Reviewed by Ravi Kumar
on
10:47 AM
Rating:

No comments: