Thursday, June 26, 2008

Previewing image while opening ASP.NET

Previewing image while opening

We can use the following code to preview an image while opening it using ASP.NET, C#, Java script.

var lastfieldname = ''
function preview(i)
var file = i.value
if (file.length<=0) return;
var ipreview = document.all('ipreview')
ipreview.src ='file://' + file
img id="ipreview" border="1" height="120" src="images/spacer.gif" /><br />
adjust image:
<input id="fotofp" runat="server" name="file1" onchange="preview(this)" onfocus="preview(this)" size="25" type="file" />

No comments: