.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Post New Resource Bookmark and Share   

Rotate Images in Asp.net

Posted By:Hiren Soni       Posted Date: August 22, 2010    Points: 25    Category:    URL: http://www.dotnetspark.com  

Rotate Images in Asp.net
 

Subject: Rotate Images in Asp.net

 

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

After clicking on button it will rotate and shown as:

 

.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.

 

 




     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend