Click here to Skip to main content
12,758,462 members (29,653 online)
Click here to Skip to main content
Add your own
alternative version


1 bookmarked
Posted 11 Oct 2013

Add Images in Image Rotator with the Help of FileUpload Control

, 18 Oct 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
How to add images in Image Rotator with the help of FileUpload control

Editorial Note

This articles was originally at but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.


In case of ImageRotator, we can use FileUpload control to upload my images.

Here I use it in a simple way.

Step 1

We use a image control (Image1), FileUpload control, button (Button1), HiddenField (for storing the file name) and a Save button to call the JavaScript function.

Step 2

On the click of Button1, we upload a file with the help of FileUpload1 and store the file name in HiddenField1 and show the image in the image control.

string filename = FileUpload1.PostedFile.FileName.ToString();
FileUpload1.SaveAs(Server.MapPath("~/") + filename);
Image1.ImageUrl = filename.ToString();
HiddenField1.Value = filename.ToString();

Step 3

On the click of Button2, we upload a file with the help of FileUpload2 and store the file name in HiddenField2 and show the image in the image control:

string filename = FileUpload2.PostedFile.FileName.ToString();
FileUpload2.SaveAs(Server.MapPath("~/") + filename);
Image1.ImageUrl = filename.ToString();
HiddenField2.Value = filename.ToString();

Step 4

On the click of Button3, we upload a file with the help of FileUpload3 and store the file name in HiddenField3 and show the image in the image control.

string filename = FileUpload3.PostedFile.FileName.ToString();
FileUpload3.SaveAs(Server.MapPath("~/") + filename);
Image1.ImageUrl = filename.ToString();
HiddenField3.Value = filename.ToString();

Suppose we add only three Images for ImageRotator.

Step 5

In the click of the Save Button (HTML control) we call the JavaScript function (show()) in the OnClick event.

<script language="javascript" type="text/javascript" >
    function show()
        var a=document.getElementById('HiddenField1').value;

    function show2()
        var b=document.getElementById('HiddenField2').value;
    function show3()
        var b=document.getElementById('HiddenField3').value;


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

ASP.NET Community
United States United States
The ASP.NET Wiki was started by Scott Hanselman in February of 2008. The idea is that folks spend a lot of time trolling the blogs, googlinglive-searching for answers to common "How To" questions. There's piles of fantastic community-created and MSFT-created content out there, but if it's not found by a search engine and the right combination of keywords, it's often lost.

The ASP.NET Wiki articles moved to CodeProject in October 2013 and will live on, loved, protected and updated by the community.
Group type: Collaborative Group

769 members

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170217.1 | Last Updated 18 Oct 2013
Article Copyright 2013 by ASP.NET Community
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid