<div id ="shahid"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <div id="rights"> <div id="my" style="margin-removed150px"> <span id="profile" style="margin-removed300px;color:Red;font-size:25px;font-family:Script MT Bold ">Change Picture</span> <hr style="width:240px; size:5px; color:#2291FF"/> <asp:FileUpload ID="FileUpload1" runat="server" style="margin-left:230px;margin-top:50px" /> <br /> <asp:Button ID="Button1" runat="server" Text="Change" style="margin-left:230px;margin-top:10px" onclick="Button1_Click" /><br /> <asp:Label ID="Label1" runat="server" style="margin-left:230px;margin-top:10px" ></asp:Label> <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1"> <ProgressTemplate> <img src="image/ajax.gif" /> </ProgressTemplate> </asp:UpdateProgress> </div> </div> <div id="left"> <asp:Image ID="Image1" runat="server" Height="155px" Width="150px" /> <div id="menuwrapper"> <ul> <li><a href="#">Home</a></li> <li><a href="#">Edit Profile</a> <ul> <li><a href="#">Product 1</a> <ul> <li><a href="#">Sub Product 1</a></li> <li><a href="#">Sub Product 2</a></li> <li><a href="#">Sub Product 3</a></li> </ul> </li> <li><a href="#">Product 2</a></li> <li><a href="#">Product 3</a></li> </ul> </li> <li><a href="#">My Comments</a> <ul> <li><a href="#">Faqs</a></li> <li><a href="#">Contact Us</a></li> <li><a href="#">Where are we?</a></li> </ul> </li> <li><a href="#">Setting</a> </li></ul> </div> </div> </ContentTemplate> </asp:UpdatePanel> </div>
protected void Button1_Click(object sender, EventArgs e) { Thread.Sleep(2000); string name = FileUpload1.FileName; string ext = System.IO.Path.GetExtension(this.FileUpload1.PostedFile.FileName); //Label1.Text = name + " " + ext; if (FileUpload1.PostedFile.ContentLength == 0) { Label1.Text = "Can't upload zero length file"; Label1.ForeColor = System.Drawing.Color.Red; } else if (ext == ".jpg" || ext == ".png" || ext == ".bmp") { DateTime dt = DateTime.Now; string tme = dt.ToLongTimeString(); string[] t = tme.Split(':'); string y = ""; foreach (string x in t) { y += x; } string aa = y + "_" + name; string location = Server.MapPath("") + "\\Profilepic\\" + aa; //string location2 = Server.MapPath("")+"\\images\\" + "\\" + DropDownList1.SelectedItem.Text + aa; FileUpload1.PostedFile.SaveAs(location); //Bitmap OriginalBM = new Bitmap(location); //Size newSize = new Size(100, 100); //Bitmap ResizedBM = new Bitmap(OriginalBM, newSize); //ResizedBM.Save(location2, ImageFormat.Jpeg); string loc = aa; string SqlConnect = System.Configuration.ConfigurationManager.ConnectionStrings["Connect"].ConnectionString; SqlConnection Sqlconn = new SqlConnection(SqlConnect); SqlCommand Sqlcomm = new SqlCommand("Update signup set dpurl='"+loc+"' where email='" + Session["email"].ToString() + "'", Sqlconn); Sqlconn.Open(); Sqlcomm.ExecuteNonQuery(); Sqlconn.Close(); showpic(); } } public void showpic() { string SqlConnect = System.Configuration.ConfigurationManager.ConnectionStrings["Connect"].ConnectionString; SqlConnection Sqlconn = new SqlConnection(SqlConnect); SqlCommand sqlcomm = new SqlCommand("select * from signup where email='" + Session["email"].ToString() + "'", Sqlconn); Sqlconn.Open(); SqlDataReader dr = sqlcomm.ExecuteReader(); if (dr.Read()) { Image1.ImageUrl = "Profilepic\\" + dr["dpurl"].ToString(); dr.Close(); Sqlconn.Close(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)