Wednesday, August 5, 2009

How To: Set Image Source using Java Script

if you want to set image source from (html Button) at run time follow the following steps.

1- Create ASP.NET Web Application.
2- in Default Page Create Html Button and html Image.
3- Set Image id to "TestImage".

copy the following java script function into your default page Source

function SetImage()
{
document.getElementById('TestImage').setAttribute('src', 'Images/Water lilies.jpg');
}

4- in html Button call SetImage Method

onclick="SetImage1()"

No comments:

Post a Comment