Ich habe einen img-TagBild Resize Ausgabe in asp.net
<asp:Image ID="imgCatalog" ImageAlign="middle" Height='<%#GetImageWidth(Eval("PictureName")) %>' ImageUrl='<%#GetImageUrl(Eval("PictureName")) %>' runat="server"/>
ich will beim Laden der Seite jedes Bild, um die Größe und i verwenden getImageWidth Funktion.
public Unit GetImageWidth(object ImageName)
{
string strimagename = Convert.ToString(ImageName);
//string strimagewidth = "";
int width = 0;
if (System.IO.File.Exists(Server.MapPath(GetImageUrl(strimagename))))
{
System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath(GetImageUrl(strimagename)));
if (img.Height > 1000)
{
//strimagewidth = "535px";
**width = 535;**
------------
}
else
{
//strimagewidth = img.Width.ToString() + "px";
width = img.Width;
}
img.Dispose();
}
return Unit.Pixel(width);
}
Ich möchte die Bildhöhe einstellen nicht Bild width.but i did not Höhe Eigenschaft innerhalb der function.Can jeder Körper Hilfe