ASP.Net – How to add a adRotator with a timer event to auto refresh an ad at regular intervals

The following client side code demonstrates placing an adRotator control onto an AJAX UpdatePanel. The ad would randomly change whenever the browser is refreshed. To simulate this automatically, a Timer control is added with an interval of 5 seconds. Every 5 seconds, the Timer triggers the AsyncPostBackTrigger which refreshes the page.

<asp:Timer ID="Timer1" Interval="5000" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:AdRotator ID="AdRotator1" runat="server"
AlternateTextField="alternate_text" DataSourceID="SqlDataSource1"
ImageUrlField="image_url" NavigateUrlField="navigate_url" Target="_blank" />
</ContentTemplate>
</asp:UpdatePanel>

Leave a Reply

Your email address will not be published. Required fields are marked *