Category >
ASP.NET
|| Published on :
Tuesday, December 22, 2015 || Views:
10244
||
How to rotating image with ASP.NET 4.0 and C# with example rotating image with ASP.NET 4.0
Introduction
Here Pawan Kumar will explain how to How to rotating image with ASP.NET 4.0 and C# with example
Description
In previous post I have explained
Bootstrap style DropDownList example in ASP.Net,
Set DropDownList value based on text/value in jQuery,
How to change some text before it is sent to the client in asp.net with example,
How to sum the value of gridview column using jquery in asp.net with example,
How to compress response in asp.net with example,
How to display progress indicator during ajax call in asp.net using jQuery, and many more articles.
Now I will explain How to How to rotating image with ASP.NET 4.0 and C# with example
So follow the steps to learn How to rotating image with ASP.NET 4.0 and C# with example
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Image ID="Image1" runat="server" ImageUrl="~/tmpImage.gif" />
<br />
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</div>
</form>
</body>
</html>
Default.aspx.cs code file :-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
//get the path to the image
string path = Server.MapPath(Image1.ImageUrl);
//create an image object from the image in that path
System.Drawing.Image img = System.Drawing.Image.FromFile(path);
//rotate the image
img.RotateFlip(RotateFlipType.Rotate90FlipXY);
//save the image out to the file
img.Save(path);
//release image file
img.Dispose();
}
}
Conclusion:
So, In this tutorial we have learned, How to rotating image with ASP.NET 4.0 and C# with example
Download Source Codes