4
Answers

open file dialogue control

Photo of ajay raju

ajay raju

15y
6.9k
1

hi!
  my doubt is : how to  upload the image in asp.net.
 in vb.net we take picturebox and openfiledialogue control. we select image using openfiledialogue then image was displayed in picturebox.
my question is how to do this proceess in asp.net.
urgent sir please help me.
thank u. 

Answers (4)

0
Photo of ajay raju
NA 398 0 15y

hi! Rekha Thanks for answering. i am also display image in image control in run time how? please give a code.
give a replay soon.
thank u.
0
Photo of Rekha Singh
NA 1.3k 563.9k 15y

we have file uploader in asp.net  which uploads the image in ur asp.net page
The fileupload.aspx code is:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

 <title>File Upload Demostration</title>

</head>

 <body>

    <form id="Form1" method="post" runat="server">

     <table cellpadding="0" cellspacing="0" width="80%" align="center" border="4">

      <tr><td height="20px"></td></tr>

       <tr><td height="200px" align="center" valign="middle">

               <input id="MyFile"   type="file" size="81" name="File1" runat="server" />

                      <br /><br />

                             <asp:Button id="btnSubmit"   runat="server" Text="Submit" Width="139px" Height="30px" OnClick="btnSubmit_Click"></asp:Button>

                             <asp:Label id="lbl"   runat="server" Width="402px" Height="33px"></asp:Label>

                            

                             </td></tr></table>

                   </form>

</body>

</html>

The fileupload.aspx.cs is:

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

 

public partial class _Default : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

 

    }

    protected void btnSubmit_Click(object sender, EventArgs e)

    {

        

        if (MyFile.PostedFile.ContentLength == 0)

        {

            lbl.Text = "Cannot upload zero length file";

            return;

        }

        lbl.Text = MyFile.PostedFile.FileName;

       MyFile.PostedFile.SaveAs("c:\\UploadFile\\MyFile.PostedFile.FileName");

 

    }

}

0
Photo of Lalit M
NA 4.2k 59.2k 15y
You can assign the image that is selected from your Open File Dialog box in the following manner. You will access the file path and name using the FileName property of the OpenFileDialog.

Code Here
----------
PictureBox1.Image = Image.FromFile(FileDialog.FileName);

more info
----------
http://www.docstoc.com/docs/2151343/Week-4-Tutorial-and-Lab

0
Photo of Lalit M
NA 4.2k 59.2k 15y