Step 1 : First open a HTML editor such as Notepad.
- Open start->Notepad.
- The name of editor is "Gallery".
Step 2 : Create a Folder on a desktop.
- Right-click on desktop->new->Folder.
- Name of folder is "Tom".
Step 3 : Open Visual Studio.
- Go to file -> New->Projects.
- Crete an ASP. NET Web Application.
- Name of "Image.aspx".
Step 4 : Add a HTML file to your web application.
- Right-click on Solution Explorer.
- Add->add new item->HTML form.
- The Name of the HTML form is "slider.html".
Step 5 : Add a folder to your web application.
- Right-click on Solution Explorer.
- Add->add new folder.
- The Name of the folder is "Gallery".
Step 6 : Add a items in image folder.
- Right-click on image folder.
- Add->add Existing item.
- After that add items in folder.
Step 7 : Now in this step we define a CSS file named Photo1.css. In CSS we define all properties of sliders; that is background, border, margin, height, width, position, display etc.
Code
body
{
color:Green;
background:url('img/bg.jpg') repeat-x #CC99FF;
font:13px "Lucida Sans Unicode",Arial;
}
#SLIDE
{
background-color:#F5F5F5;
border:1px solid #FFFFFF;
height:340px;
margin:150px auto 0;
position:relative;
width:640px;
-moz-box-shadow:0 0 22px #111;
-webkit-box-shadow:0 0 22px #111;
box-shadow:0 0 22px #111;
}
#SLIDE ul
{
height:320px;
left:10px;
list-style:none outside none;
overflow:hidden;
position:absolute;
top:10px;
width:620px;
}
#SLIDE li
{
position:absolute;
display:none;
z-index:10;
}
#SLIDE li:first-child
{
display:block;
z-index:1000;
}
#SLIDE .slideActive
{
z-index:1000;
}
#SLIDE canvas{
display:none;
position:absolute;
z-index:100;
}
#SLIDE .arrow
{
height:86px;
width:60px;
position:absolute;
top:50%;
margin-top:-43px;
cursor:pointer;
z-index:5000;
}
#SLIDE .previous{ background-position:left top;left:0;}
#SLIDE .previous:hover{ background-position:left bottom;}
#SLIDE .next{ background-position:right top;right:0;}
#SLIDE .next:hover{ background-position:right bottom;}
Step 8 : Now in this step we set a path of a image in a div.
Code
<div id="slideshow">
<ul class="slides">
<li><img src="Gallery/2aaaaaaa.jpg" width="620" height="320" alt="Marsa Alam underawter close up" /></li>
<li><img src="Gallery/143392-30741-19_10_13---Spring_web.jpg" width="620" height="320" alt="Marsa Alam underawter close up" /></li>
<li><img src="Gallery/c-sharpcorner.com.jpg" width="620" height="320" alt="Marsa Alam underawter close up" /></li>
<li><img src="Gallery/1.jpg" width="620" height="320" alt="Marsa Alam underawter close up" /></li>
<li><img src="Gallery/2.jpg" width="620" height="320" alt="Turrimetta Beach - Dawn" /></li>
<li><img src="Gallery/3.jpg" width="620" height="320" alt="Power Station" /></li>
<li><img src="Gallery/4.jpg" width="620" height="320" alt="Colors of Nature" /></li>
</ul>
<span class="arrow previous"></span>
<span class="arrow next"></span>
</div>
Step 9 : Now we have used a js file named galary.js. In the js file we set a sliding functionality.
Code
function createcanOverlay(image) {
var can = document.createElement('can'),
canContext = can.getContext("2d");
can.width = slideshow.width;
can.height = slideshow.height;
canContext.drawImage(image, 0, 0);
var Img = canContext.getImg(0, 0, can.width, can.height),
data = Img.data;
for (var i = 0, z = data.length; i < z; i++) {
data[i] = ((data[i] < 128) ? (2 * data[i] * data[i] / 255) : (255 - 2 * (255 - data[i]) * (255 - data[i]) / 255));
data[++i] = ((data[i] < 128) ? (2 * data[i] * data[i] / 255) : (255 - 2 * (255 - data[i]) * (255 - data[i]) / 255));
data[++i] = ((data[i] < 128) ? (2 * data[i] * data[i] / 255) : (255 - 2 * (255 - data[i]) * (255 - data[i]) / 255));
++i;
}
canContext.putImg(Img, 0, 0);
image.parentNode.insertBefore(can, image);
}
});
Step 10 : The compete code of the application is given below.
Code
<html>
<head>
<title>Image Slider Demo</title>
<link rel="stylesheet" type="text/css" href="photo1.css" />
<body>
</head>
<div id="slideshow">
<ul class="slides">
<li><img src="Gallery/2aaaaaaa.jpg" width="620" height="320" alt="Marsa Alam underawter close up" /></li>
<li><img src="Gallery/143392-30741-19_10_13---Spring_web.jpg" width="620" height="320" alt="Marsa Alam underawter close up" /></li>
<li><img src="Gallery/c-sharpcorner.com.jpg" width="620" height="320" alt="Marsa Alam underawter close up" /></li>
<li><img src="Gallery/1.jpg" width="620" height="320" alt="Marsa Alam underawter close up" /></li>
<li><img src="Gallery/2.jpg" width="620" height="320" alt="Turrimetta Beach - Dawn" /></li>
<li><img src="Gallery/3.jpg" width="620" height="320" alt="Power Station" /></li>
<li><img src="Gallery/4.jpg" width="620" height="320" alt="Colors of Nature" /></li>
</ul>
<span class="arrow previous"></span>
<span class="arrow next"></span>
</div>
<script src="Scripts/galary.js"></script>
<h1>Tom Develop a Slider image</h1>
</body>
</html>
Step 11 : The following shows an image of the complete application.
Step 12 : Press Ctrl + F5 to run the application in a browser.
Output
Click a corner of the image; after that change a image one by one.
Resources
Here is some useful resources :