Click here to Skip to main content
Rate this: bad
good
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;
UploadPhoto.SaveAs(Server.MapPath(UploadFolderPath));
 
if (UploadFolderPath.ToLower().EndsWith(".jpg"))
{
cmdAdmission.Parameters.Add(new SqlParameter("@Photo_Path", SqlDbType.NVarChar,200));
 
cmdAdmission.Parameters["@Photo_Path"].Value = UploadFolderPath;
}
}
else
{
//here i have to take default Profile Pic
}
Posted 20-Feb-13 21:48pm
ntitish1.6K
Edited 20-Feb-13 22:17pm
v3
Comments
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
   
thanks...

1 solution

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

Solution 1

else
{
 
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.
  Permalink  
v2
Comments
ntitish at 21-Feb-13 3:32am
   
thanks
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)



Advertise | Privacy | Mobile
Web02 | 2.8.150327.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