Hi friends,in this article I will explain about How To Use the AdRotator Control in an ASP.NET .
I already explained in the previous articles about How to Bind Nested Gridview from Database in asp.net with C#/VB.NET,Marquee tag or How to Scroll Text From left to right or How to Move the Text in HTML,C#/VB.NET:Save the generated pdf directly to the server directory folder without user prompt in ASP.NET and JQuery:How to Display Current Date and Time on Webpage using ASP.NET
In ASP.NET page write the below code.
ASP.NET:
I already explained in the previous articles about How to Bind Nested Gridview from Database in asp.net with C#/VB.NET,Marquee tag or How to Scroll Text From left to right or How to Move the Text in HTML,C#/VB.NET:Save the generated pdf directly to the server directory folder without user prompt in ASP.NET and JQuery:How to Display Current Date and Time on Webpage using ASP.NET
In ASP.NET page write the below code.
ASP.NET:
<html>
<head>
<title>AdRotator in ASP.NET</title>
</head>
<body>
<form id="Form1"
runat="server">
<asp:AdRotator ID="AdRotator1"
AdvertisementFile="AdRotator.xml" runat="server" OnAdCreated="Navigate_URL" target="_search" />
<h5><a href="AdRotator.xml"
target="_search">View
AdRotator XML Code.</a></h5>
</form>
</body>
</html>
|
Take one .xml file,name it as AdRotator.xml and write the following code.
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>https://www.google.com/images/srpr/logo11w.png</ImageUrl>
<NavigateUrl>http://www.google.com</NavigateUrl>
<AlternateText>Google</AlternateText>
<Impressions>50</Impressions>
<Keyword>Search</Keyword>
</Ad>
<Ad>
<ImageUrl>https://www.google.co.in//logos/doodles/2013/cv-ramans-125th-birthday-5688529564729344-hp.jpg</ImageUrl>
<NavigateUrl>http://www.google.com</NavigateUrl>
<AlternateText>Google</AlternateText>
<Impressions>50</Impressions>
<Keyword>Search</Keyword>
</Ad>
</Advertisements>
|
In C#.NET:
protected void Navigate_URL(object sender,
AdCreatedEventArgs e)
{
e.NavigateUrl="http://www.Google.com" ;
}
|
In VB.NET:
Protected Sub Navigate_URL(ByVal sender As Object, ByVal e As AdCreatedEventArgs) Handles
Me.Load
e.NavigateUrl = "http://www.Google.com"
End
Sub
|
The output of the above page as shown in the below figures.
No comments:
Post a Comment