JPG不工作的ASP图片 [英] JPG not working on ASP Image
问题描述
我在ASP.NET中的Image对象
我分配一个的ImageUrl来,但我注意到,它并没有显示的事情,当它从不同PNG格式。
I have an Image object in ASP.NET I am assigning an ImageUrl to it but I'm noticing that it does not display a thing when it's a format different from PNG.
在这种情况下,我需要接受JPG。有什么可以做?
In this case, I need it to accept JPG. What can be done?
<table>
<tr>
<td>
<strong>
Foto
</strong>
<br/>
<asp:Image ID="Image1" runat="server" ToolTip="Foto" Width="320px" Height="240px" ImageUrl='<%# "C:/Images/pictures/" + Eval("picture") %>' />
</td>
<td />
<td>
<strong>
Firma
</strong>
<br/>
<asp:Image ID="imgSignature" runat="server" ToolTip="Firma" Width="320px" Height="240px" ImageUrl='<%# "C:/Images/signatures/" + Eval("signature") %>' />
</td>
</tr>
</table>
picture = 1.jpg
signarute = 2.png
第一个不工作,第二个呢。
这是一个gridview的行内。
the first one is not working, the second one does. This is inside a gridview row.
推荐答案
您不能使用图像的物理文件路径。你要么需要使用绝对路径,或者更简单地说,相对路径,如〜/图片/签名/ myImage.jpg
:
You can't use physical file paths for images. You either need to use the absolute path, or more simply, the relative path, like ~/Images/signatures/myImage.jpg
:
<asp:Image ID="imgSignature" runat="server" ToolTip="Firma" Width="320px" Height="240px" ImageUrl='<%# "~/Images/signatures/" + Eval("signature") %>' />
侧面说明,你不应该使用的布局/格式表。使用CSS。
Side note, you shouldn't use tables for layout / formatting. Use CSS.
这篇关于JPG不工作的ASP图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!