Hello All;
Could someone convert this from ASP.NET -over-to- ASP?
Thank you.
Carrzkiss
==========================
==========
==========
==========
==========
====
<%@ Page Language="C#" %>
<%@ import Namespace="System.IO" %>
<script runat="server">
// This function return the tag string to resize an image at the desired MaxWidth and MaxHeight, maintaining the image Height/Width Ratio
string COMMONFUNCTIONS_IMAGES_RES
IZE_TO_TAG
(System.Dr
awing.Imag
e img, int MaxWidth, int MaxHeight)
{
if (img.Width > MaxWidth || img.Height > MaxHeight)
{
double widthRatio = (double) img.Width / (double) MaxWidth;
double heightRatio = (double) img.Height / (double) MaxHeight;
double ratio = Math.Max(widthRatio, heightRatio);
int newWidth = (int) (img.Width / ratio);
int newHeight = (int) (img.Height / ratio);
return " width=\"" + newWidth.ToString() + "\"" + " height=\"" + newHeight.ToString() + "\" ";
}
else
{
return "";
}
}
private void LoadImage()
{
// sets the name of the image
string imageUrl = "emanuelebriano.gif";
// gets width and height
int Img_Width = Int32.Parse(txtWidth.Value
);
int Img_Height = Int32.Parse(txtHeight.Valu
e);
// gets the image width and height tag
string s_ImageSize = " width=\"0\" height=\"0\" ";
if (File.Exists(Server.MapPat
h(imageUrl
)))
{
System.Drawing.Image img = System.Drawing.Image.FromF
ile(Server
.MapPath(i
mageUrl));
s_ImageSize = COMMONFUNCTIONS_IMAGES_RES
IZE_TO_TAG
(img, Img_Width, Img_Height);
}
// draw the image
divImage.InnerHtml = "<img src=\"" + imageUrl + "\" border='1' " + s_ImageSize + " />";
divDim.InnerHtml = s_ImageSize;
}
void Button1_Click(object sender, EventArgs e) {
LoadImage();
}
</script>
<!-- Code by Emanuele Briano ---
http://www.emanuelebriano.it -->
<html>
<head>
</head>
<body>
<form runat="server">
<div id="divImage" runat="server">Image will be loaded here
</div>
<div id="divDim" runat="server">
</div>
<br />
<br />
<br />
<br />
<div>maxWidth:
<input id="txtWidth" type="text" value="300" runat="server" />
maxHeight:
<input id="txtHeight" type="text" value="100" runat="server" />
</div>
<div>
<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Load"></asp:Button>
</div>
<div>
</div>
<div>Code by <a href="
http://www.emanuelebriano.it">
Emanuele Briano</a>
</div>
</form>
</body>
</html>
==========================
==========
==========
==========
==========
====