Microsoft.NET

……………………………………………….Expertise in .NET Technologies

ImageRotator

Posted by Ravi Varma Thumati on October 26, 2009

Introduction

I have always been interested in Web controls, but never had a chance to use one. So here is my very first one. This control shows images in a slide show manner. As soon as the page is finished loading, the slideshow starts. There are three buttons on the top of the image. Here, the slideshow can be stopped and started. It is also possible to use the Previous and Back buttons to cycle through the images manually.

Using the control

Just drop the control on an ASPX page. You will need to add an image folder to your project and fill this folder with the images you would like to display in the control. Next, tell the control where to look for the images. Write the virtual path to the property imageFolder. All the additional properties are described in detail below.

That is it. Start the application and watch the image rotator do it work.

Properties

  • imageFolder: Tells the control where to load the images from. The control will attempt to show all files in this folder. For this reason, you should only add files that can be shown in an ‘img src’ tag to this folder.
  • timerinterval: Sets the interval between the images in the slideshow. Values are in milliseconds. Default is 1000.
  • imageWidth: Specifies the image width in pixels. If this value is blank, the width of the image is used.
  • imageHeight: Specifies the image height in pixels. If this value is blank, the height of the image is used.
  • toggleStartText: The text to be displayed for the Start button. Default is Start.
  • toggleStopText: The text to be displayed for the Stop button. Default is Stop.
  • nextText: The text to be displayed for the Next button. Default is Next.
  • previousText: The text to be displayed for the Previous button. Default is Previous.
  • buttonStyle: The style to be applied to all three buttons.
  • startImage: The image to be displayed first when the slideshow starts.

Conclusion

Since this is the first web control I authored, I started with a clean slate. I started by writing the functionality I wanted in HTML and JavaScript. I figured at the end of the day a web control does nothing else than write HTML and JavaScript to the browser. If you look at the source code, you will find Regions labeled Original Function. In these regions is the original HTML/JavaScript I wrote. I thought about the functionality I wanted to expose, and wrote the properties respectively. At this point, all I needed to do was write the original code in the method RenderContents and insert the values of the properties where appropriate. I split the JavaScript methods and control elements to separate methods to make the code more legible.

Hope this code helped you to find a solution to a problem.

 

Advertisements

2 Responses to “ImageRotator”

  1. Hello there, are you having difficulties with the web hosting? I had to refresh the page about million times to be able to get the page to load

  2. Pretty good article. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be coming back and I hope you post again soon.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: