Reputation: 1011
This is my fifth day trying to Rotate Image in my Web Application ASP.NET, all the solutions in the internet didn't work with me.
This is my code in .aspx.cs
protected void BtnRotateImage_Click(object sender, EventArgs e)
{
string vImageName = LblFarmId.Text;
string vPath = "~/attachments/survey/" + vImageName + ".jpg";
Image1.ImageUrl = vPath;
//get the path to the image
string path = Server.MapPath(vPath);
//create an image object from the image in that path
System.Drawing.Image img = System.Drawing.Image.FromFile(path);
//rotate the image
img.RotateFlip(RotateFlipType.Rotate90FlipXY);
//save the image out to the file
img.Save(path);
//release image file
img.Dispose();
}
In .aspx page
<asp:Image ID="Image1" runat="server" ImageUrl="" width="600" height="800"/>
I click on the button, nothing happen , the image doesn't rotate.
is there any wrong in my code?
Upvotes: 2
Views: 2088
Reputation: 52
When you click the button, you are only saving the image. After the image is saved, you need to reload the page with the image tag set to the new path.
Upvotes: 1