ARTICLE

Image rotation in ASP.Net

Posted by Dinkar Chavhan Articles | ASP.NET Controls in C# April 12, 2011
Learn how to perform image rotation in ASP.Net.
Reader Level:

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'>
Login to add your contents and source code to this article
post comment
     

Thanks

Posted by Dinkar Chavhan Apr 14, 2011

nice one...

Posted by Dinesh Beniwal Apr 14, 2011
COMMENT USING
PREMIUM SPONSORS
Over-C is a holistic consortium of communications and technology specialists. We build, deploy and market both business as well as consumer products and solutions.
Join a Chapter
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Join a Chapter