Image Handling

Image handling can be done by two ways-

1. Using controls.

2. Using code.

Using controls-

a) Image Control- ImageUrl is the property of Image control.  

b) ImageButton Control- ImageUrl, PostBackUrl

Steps to add image in image control- 

i.   Create a directory in your project. 

ii.  Add an image in that directory. 

iii. Refresh the solution explorer(In dot net). 

iv. Now, Go to the properties of Image control> ImageUrl> Click on the dots > Select the image from the dialog box 

======================================

 File Upload Control- It allows us to Upload Image to a server or store in web form. 

Drag n Drop File Upload Control from tool box, take a button control beside it[Name it as Upload],Image control.

When we browse the file and click on Upload button, the image will be stored in the folder we have created earlier and be shown in the Image control.  

FileUpload1.SaveAs(Server.MapPath("~") + "//Photo//" + FileUpload1.FileName); 

[The above code is used to store the image in "Photo" folder.]

"~" - tilde Symbol reads the root folder.

Server.MapPath() - It indicates the location. 

Folder works in SaveAs property- We can any number of files in a folder. 

Image1.ImageUrl = "~/Photo/" + FileUpload1.FileName; 

[The above code is used to display the image in Image Control]





Comments

Popular posts from this blog

Parameter Query

Final Project

Grid View Paging