SIGN UP MEMBER LOGIN:    
ARTICLE

How to rotate images in Asp.net

Posted by Hiren Soni Articles | ASP.NET Programming August 20, 2010
Here I will show you how you can rotate image in web page in asp.net.
Reader Level:

Here I will show you how you can rotate image in web page in asp.net.

1.gif 

After clicking on button it will rotate and shown as:
 
2.gif

.aspx code:

<asp:Image  ImageUrl="~/H.GIF" ID="Image1" runat="server" />
<asp:Button ID="Button1" runat="server"  Text="Button" onclick="Button1_Click2" />

Here I have taken one Image Control and One button.

.aspx.cs code (code- behind page)

protected void Button1_Click2(object sender, EventArgs e)
{
    // get the full path of image url
    string path = Server.MapPath(Image1.ImageUrl) ;

    // creating image from the image url
    System.Drawing.Image i = System.Drawing.Image.FromFile(path);

    // rotate Image 90' Degree
    i.RotateFlip(RotateFlipType.Rotate90FlipXY);

    // save it to its actual path
    i.Save(path);

    // release Image File
    i.Dispose();

    // Set Image Control Attribute property to new image(but its old path)
    Image1.Attributes.Add("ImageUrl", path);
}

Hope you understand it.

Thank you.

Login to add your contents and source code to this article
share this article :
post comment
 
Nevron Gauge for SharePoint
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor