vijay

welcome Netizen

Share Your Knowledge.It is a way to achieve immortality

Thursday, December 29, 2011

Preview image before upload using javascript in asp.net or preview image using fileupload control


Introduction:
Hi
Here I have share the code ..to preview the image before store into database.
Description:
This easy code to preview image before upload to database using file upload control. This code will work only IE 7 and IE 8 then firefox ,chrome…
Code:
<head id="Head1" runat="server">
    <title>Untitled Page</title>
       <meta http-equiv="X-UA-Compatible" content="IE=8"/>
        <script language="javascript" type="text/javascript">
        function PrevImg(imgFile) {
            var Preview = document.getElementById("Image1");
           Preview.src = imgFile.value;
            Preview.style.width = "200px";
            Preview.style.height = "150px";
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        preview
        <asp:FileUpload ID="Fud_Pic" runat="server" onchange="PrevImg(this)" />
       
        <asp:Image ID="Image1" runat="server" />
      
       
    </div>
  
    </form>
</body>

Sample preview:


i hope this helpfull to all

post your comments here.........

0 comments:

Post a Comment