Introduction
Browse or upload option is one of the most necessary feature of websites like photography, images, e books etc. So here am showing you on of the easiest path to create a browse option for your application or website.
There are three steps in creating a browse/upload option for your website, application, portal and so on.
Step 1
In SQL Server:
First of all we need to create a database in SQL Server, so for that we can define the values of attributes like this; for example: for images, we need to create something like:
Column Data Type
Img image

[Full Table Page]
[Table]
Step 2
In Visual Studio:
Use the following procedure to create a sample in Visual Studio:
- Open the Tool Box
- File uploads (from TOOL box):
- In standard tool option

- Put a BUTTON (Upload)
- On a button click event
- now click on the browse button option
- it will generate a .cs file
Step 3
Coding
The following is the code for the .cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
public partial class profile : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string imagebyte;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ABC"].ConnectionString);
con.Open();
if (FileUpload1.HasFile)
{
if (FileUpload1.PostedFile.ContentType == "image/jpg")
{
if (FileUpload1.PostedFile.ContentLength < 102400)
{
int Length = FileUpload1.PostedFile.ContentLength;
Image.InputStream.Read(imagebyte, 0, Length);
SqlCommand cmd = new SqlCommand("insert into Signup(Image) values(@image)", con);
cmd.Parameters.Add("@image", imagebyte);
cmd.ExecuteNonQuery();
Label1.Text = ("Insert");
}
else
{
Label1.Text = ("SelectFile");
}
}
}
}
}
Example


Abhishek JaiswalPosted Sep 26, 2014, 4:11 PM
Nupur, pls check this URL for more info: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.webpartverb.imageurl(v=vs.110).aspx
Abhishek JaiswalPosted May 25, 2014, 1:12 AM
In .Net, you need to have a System.Web.UI.WebControls.Image in your web form and assign the ImageUrl property the URL of the image to be displayed.
Umar AbiolaPosted May 24, 2014, 7:39 PM
please i keep having this error "'System.Web.UI.WebControls.Image' does not contain a definition for 'InputStream' " and i tried incluing all classes(namespaces) i think should work with it yet it didn't work.. am using visual studio 2012 ..pls solve thsi pls
Abhishek JaiswalPosted Dec 7, 2013, 5:27 AM
thank u .. and what kinda changes ...?
Srihari ChinnaPosted Dec 7, 2013, 5:13 AM
good one but.. need some changes to the code