hi
i use these code for resizing image
behind code
public string img_resize(string picname, int maxHeight, int maxWidth)
{
System.Drawing.Image currentImage = System.Drawing.Image.FromFile(server.mappath("mypics\\") + picname);
double imgHeight = 0;
double imgWidth = 0;
imgHeight = currentImage.Height;
imgWidth = currentImage.Width;
if (imgWidth > maxWidth | imgHeight > maxHeight)
{
//Determine what dimension is off by more
double deltaWidth = imgWidth - maxWidth;
double deltaHeight = imgHeight - maxHeight;
double scaleFactor = 0;
if (deltaHeight > deltaWidth)
{
//Scale by the height
scaleFactor = maxHeight / imgHeight;
}
else
{
//Scale by the Width
scaleFactor = maxWidth / imgWidth;
}
imgWidth *= scaleFactor;
imgHeight *= scaleFactor;
}
string html = null;
html = "<img src=\"" + picname + "\" height=\"" + imgHeight + "\" width=\"" + imgWidth + ">\"";
return html;
}
public void img_resize(string picname, int maxHeight, int maxWidth)
{
System.Drawing.Image currentImage = System.Drawing.Image.FromFile(Server.MapPath("image/house\\") + picname);
double imgHeight = 0;
double imgWidth = 0;
imgHeight = currentImage.Height;
imgWidth = currentImage.Width;
if (imgWidth > maxWidth | imgHeight > maxHeight)
{
//Determine what dimension is off by more
double deltaWidth = imgWidth - maxWidth;
double deltaHeight = imgHeight - maxHeight;
double scaleFactor = 0;
if (deltaHeight > deltaWidth)
{
//Scale by the height
scaleFactor = maxHeight / imgHeight;
}
else
{
//Scale by the Width
scaleFactor = maxWidth / imgWidth;
}
imgWidth *= scaleFactor;
imgHeight *= scaleFactor;
}
string html = null;
html = "<img src=\"" + picname + "\" height=\"" + imgHeight + "\" width=\"" + imgWidth + ">\"";
}
design view
<asp:GridView ID="GridView3" runat="server" AllowPaging="True" AllowSorting="True"AutoGenerateColumns="False" DataKeyNames="reply_pk" DataSourceID="reply_source"Width="100%" GridLines="None">
<Columns>
<asp:TemplateFieldSortExpression="reply_user">
<ItemTemplate>
<%#img_resize(Eval("my_img"),100, 80)%>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
but in this line occur error
<ItemTemplate> <%#img_resize(Eval("my_img"),100, 80)%> </ItemTemplate>
error:
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: The server tag is not well formed.
what should i do ?
best regards