/* This event is use to add an friend detail to database with image also keep image ratio*/ protected void AddUser_Click(object sender, EventArgs e) { if (flUploadDetail.PostedFile != null) { string ImageName2 = System.IO.Path.GetFileName(flUploadDetail.PostedFile.FileName); if (ImageName2 != "") { string ext = System.IO.Path.GetExtension(flUploadDetail.FileName).ToLower(); if (ImageName2 != "" && ext == ".gif" || ext == ".jpg" || ext == ".png" || ext == ".GIF" || ext == ".jpeg" || ext == ".JPEG" || ext == ".PNG" || ext == ".JPG") { string NewImageName = RandomStringsAndNumbers.Generate() + ext; string virtualpath2 = Session["HomePath"] + "StoreData/FriendLogo/" + NewImageName; string fullpath2 = ContentManager.GetPhysicalPath(virtualpath2); System.Drawing.Image image = System.Drawing.Image.FromStream(flUploadDetail.PostedFile.InputStream); Bitmap myBitmap = ResizeImage(flUploadDetail.PostedFile.InputStream, 75, 50); myBitmap.Save(fullpath2, System.Drawing.Imaging.ImageFormat.Jpeg); myBitmap.Dispose(); Global ObjFriend = new Global(); ObjFriend.AddFriend(txtTitle.Text.Trim(), txtDescription.Text.Trim(), NewImageName, txtReferallink.Text.Trim()); txtTitle.Text = ""; txtReferallink.Text = ""; txtDescription.Text = ""; SuccessMessage("Friend added successfully"); } else { ErrorMessage("File Format Not Supported"); } } else { ErrorMessage("You Forgot To Select File Please Select File & Then Try."); } } else { ErrorMessage("You Forgot To Select File Please Select File & Then Try."); } }