SNB Solutions - Baja California Software Company
Welcome Guest Search | Active Topics | Log In | Register

Tag as favorite
Adding advert rotator to your web app
stoian_bycovich
#1 Posted : Friday, February 26, 2010 2:49:44 PM

Rank: Administration

Medals:

Groups: Administrators
Joined: 1/2/2010
Posts: 79
Points: 10,237
Location: Cabo San Lucas

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
I am going to show you how you can easy add cool advertisement banner rotator to your web applications, because in our days most important for your web pages to be successful is to "catch" the eye of your visitors and make them stay as long as possible. Ok first i will start from aspx code.

Drag and drop Timer control (by the way I am using ajax control toolkit which is offered for free from codeplex and you can download it from here ).

<asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick" />

for time interval you can set whatever value you like in miliseconds (this is the changing image speed of your adds). OnTick, this is the place where I am going to use the tick event of the timer control.

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>

<asp:AsyncPostBackTrigger ControlID="Timer1" />
</Triggers>

<ContentTemplate>
<asp:Image ID="img" runat="server" ImageUrl="~/Images/1.gif" />

</ContentTemplate>
</asp:UpdatePanel>



Second place an update panel and set the triger ControlID to Timer1 which is the ID of our timer control, and the Content Template where you can place whatever control you like (I've used just simple image).

Now, its time to work around the code behind and to "connect" our images with the timer ticking.

Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim ran As Integer = New Random().Next(1, 9)
img.ImageUrl = "~/Images/" & ran & ".gif"

End Sub

I am generating random number from 1 to 9 when the timers time runs out and setting the image url attribute to an image name which by the way I've placed in folder "Images" and named them 1.gif, 2.gif ...9.gif.

Well thats it ....simple.



Have fun

Best regards,
Stoyan Bukovich
Executive manager
SNB Solutions

Cell.: +52 6241 616969
E-mail: s.bucovich@snb-bg.com
Web: www.snb-bg.com
Sponsor  
 
Eannouncements.net SNB Solutions Eanuncios.net

Eannouncements.net the place for your announcement.

SNB Solutions - Software and computing services company.

Eanuncios.net el lugar para su anuncio.

Users browsing this topic
Guest
Tag as favorite
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.