Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
C#
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
Updated 20-Feb-13 21:17pm
v3
Comments
maxrockM 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 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 21-Feb-13 7:22am    
sir i am getting......thanks
ntitish 21-Feb-13 3:31am    
thanks...

1 solution

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.
 
Share this answer
 
v2
Comments
ntitish 21-Feb-13 3:32am    
thanks
Surendra0x2 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
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900