Pages

Subscribe:

Ads 468x60px

Thursday, 8 September 2011

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="247pxImageUrl="~/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.

0 comments:

Post a Comment