>[Bindable(true, BindingDirection.TwoWay), Category("User-Defined"), Description("Default Picture")] >public byte[] DefaultPicture >{ > get > { > // We need to convert picture to byte array > Byte[] imgByte = null; > try > { > > if (this.myPic.HasFile && this.myPic.PostedFile != null) > { > if (this.myPic.FileBytes.Length > 10240) // exception case > throw new Exception("Image File was is too big: " + > (this.myPic.FileBytes.Length / 1024).ToString() + " kB."); > else > imgByte = this.myPic.FileBytes; > } > } > catch (Exception e) > { > throw (e); > //exception handled > } > return imgByte ; > } > > set > { > if (this.pnlImage.Visible == true) > { > //Here we need to set picture using JavaScript - ClientScriptManager > string Request_PhysicalPath = Request.PhysicalPath; > string Request_FilePath = Request.FilePath; > string dir = Request_PhysicalPath.Substring(0, (Request_PhysicalPath.Length - Request_PhysicalPath.Split('\\')[Request_PhysicalPath.Split('\\').Length - 1].Length)); > > string[] delFiles = Directory.GetFiles(dir, "*aspx*" + Profile.UserName + "*.jpg"); > for (int i = 0; i < delFiles.Length; i++) > { > File.Delete(delFiles[i]); > } > > string imgName = this.PersonID + Profile.UserName + ".jpg"; > if (value == null || value.ToString() =="") > { > String dImg = dir + "icon_no_photo_80x80.gif"; > File.WriteAllBytes(Request_PhysicalPath + imgName, (byte[])File.ReadAllBytes(dImg)); > } > else > { > File.WriteAllBytes(Request_PhysicalPath + imgName, value); > } > this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowPic", "previewImage('" + Request_PhysicalPath + imgName + "')", true); > // picresult.src = Request_PhysicalPath + imgName; > } >}>
DefaultPicture = '< %# Bind("DefaultPicture") % >'
>