Click here to Skip to main content
11,580,572 members (68,975 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET
Up to uploading the profile pic i have completed but i am facing problem in uploading default profile pic when the user not uploaded his profile pic

//below is my code for upload profile pic
if (UploadPhoto.HasFile)
string UploadFolderPath = "Profile_Pic\\" + txtChildName.Text + "_";
UploadFolderPath = UploadFolderPath + UploadPhoto.FileName;
if (UploadFolderPath.ToLower().EndsWith(".jpg"))
cmdAdmission.Parameters.Add(new SqlParameter("@Photo_Path", SqlDbType.NVarChar,200));
cmdAdmission.Parameters["@Photo_Path"].Value = UploadFolderPath;
//here i have to take default Profile Pic
Posted 20-Feb-13 20:48pm
Edited 20-Feb-13 21:17pm
maxrockM at 21-Feb-13 3:21am
If you want to show some default image for profile pic, you might as well place the default image in the images folder and during loading, check whether the user has a pic uploaded or not and if he does not have a pic then just show the image which is in the image folder. Will this not work for you?
ntitish at 21-Feb-13 7:15am
i am unable to display while picking from database

//here is my code for displaying the image
imgbtnProfilePic.ImageUrl = ViewState["Photo_Path"].ToString();
imgbtnProfilePic.ToolTip = name;
ntitish at 21-Feb-13 7:22am
sir i am getting......thanks
ntitish at 21-Feb-13 3:31am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


string defaultpic="shadowimage.jpg";

sqlcomm.Parameters.Add("@profilepic", SqlDbType.VarChar, 200).Value = defaultpic;

In Profilepic folder add this shadowimage.jpg then

on welcome page Image1.ImageUrl="Profilepic\\"+dr["pic"].ToString()
show that pic if user did not upload his pic.
ntitish at 21-Feb-13 3:32am
Surendra0x2 at 21-Feb-13 3:36am
Nitish if u found my answer helpful then accept it :) thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Frankie-C 195
1 OriginalGriff 184
2 F-ES Sitecore 80
3 Andy Lanng 75
4 Afzaal Ahmad Zeeshan 75
0 OriginalGriff 1,108
1 Sergey Alexandrovich Kryukov 785
2 Abhinav S 622
3 F-ES Sitecore 500
4 Suvendu Shekhar Giri 433

Advertise | Privacy | Mobile
Web04 | 2.8.150603.1 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100