mvc and img tags, which to use?
when specifying the src of an img tag, must i convert the relative path to absolute? please post example开发者_StackOverflows and why not use runat="Server"
Because ASP.NET MVC views are in a separate folder, your best option is to use the
<%= Url.Content("~/ImagesFolder/image.gif") %>
to get the exact path of the image.
All Url.Content does is return the exact path of a specific file using its relative url so it can be used for ANY file in your web application (.js .css .txt etc.).
Alternatively, a better implementation for images is Html.Image() which is available in the MVC Futures (I can't find the .dll link) and I think in the new version of ASP.NET MVC
If you can't find them, check out this post
Where is Html.Image in ASP .NET MVC RC?
<img src="<%=Url.Content("~")%>MyImageFolder/logo.png"/>
runat=server creates a server control in the code behind, it is not really a usefull concept in MVC where you would not want to access properties of the control on the server.
精彩评论