Image rotation in ASP.Net


This code for image rotation is simple so we will start step by step.

Step 1) Take an image and button control; code like:

{
<form id="form1" runat="server">
     <div>
   
         <asp:Image ID="Image1" runat="server" Height="178px" Width="247px
ImageUrl="~/images/2168NN97_4[1].jpg" />
   
     </div>
     <asp:Button ID="Button1" runat="server" Text="&gt;&gt;" 
         OnClick="Button1_Click"/>
}
 

Step 2) Double-click on the button and write code as follows:

{
protected void Button1_Click(object sender, EventArgs e)
      {
        string p = Server.MapPath(Image1.ImageUrl);
        System.Drawing.Image i = System.Drawing.Image.FromFile(p);
        i.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipX);
        i.Save(p);
        i.Dispose();
        Image1.Attributes.Add("ImageUrl",p);
      }
}

Step 3)

Now execute the application and verify that it runs as expected.

erver'>
Up Next
    Ebook Download
    View all
    Learn
    View all