vijay

welcome Netizen

Share Your Knowledge.It is a way to achieve immortality

Wednesday, February 16, 2011

How to rotate the ads without refreshing the page by using Adrotator in Ajax....


hi ..Create your own add in your webpage..
In this article i describe about ,how to display the ads in webpage by using adrotator,
By using AJAX without refreshing the whole page you can easily display the diffrent ads in the particular area....
Intially the ads are stored in xml file ..
First you have to create the xml file for ads.

<Advertisements>
<Ad1>
<ImageUrl>~/images/color.jpg</ImageUrl>
<NavigateUrl>http://www.google.com</NavigateUrl>
<AlternateText>This is Sample image</AlternateText>
<Impressions>40</Impressions>
<Keyword>small</Keyword>
<width>300</width>
<Height>50</Height>
</Ad1>
<Ad2>
<ImageUrl>~/images/sample1.jpg</ImageUrl>
<NavigateUrl>http://www.yahoo.com</NavigateUrl>
<AlternateText>This is Sample image</AlternateText>
<Impressions>40</Impressions>
<Keyword>small</Keyword>
<width>300</width>
<Height>50</Height>
</Ad2>
</Advertisements>

and save it advertisement.xml

Next create an new applications

In this adrotator->>you can finthis one in toolbox
Add Script Manage and timer
and add update panel
In this adrotator properties you can add the advertisement xml file
And also  set the time for rotating the ad in the timer control

Your code should be like this....

 <asp:scriptmanager ID="Scriptmanager1" runat="server"></asp:scriptmanager>
    
    <asp:Timer ID="Timer1" Interval="2000" runat="Server">
</asp:Timer>
<asp:UpdatePanel ID="updatepanel1" runat="Server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" Eventname="Tick" />
</Triggers>
<ContentTemplate>


    <asp:AdRotator ID="AdRotator2" runat="server" DataSourceID="XmlDataSource2" />
    <asp:XmlDataSource ID="XmlDataSource2" runat="server" DataFile="~/Advertisements.xml">
    </asp:XmlDataSource>
 </ContentTemplate>
</asp:UpdatePanel>

Your add should be like this ..........

0 comments:

Post a Comment