【发布时间】:2009-09-11 08:03:27
【问题描述】:
我是 asp.net mvc 的新手,但我正在尝试用 GDI+ 做一个有趣的应用程序,我需要用 asp.net mvc 做一些图像视图。
我有一个具有图像属性的模型:
namespace DomainModel.Entities
{
public class BackgroundImage
{
// Properties
public Image Image {get; private set; }
public BackgroundImage()
{
Image = Image.FromFile(@"D:\ProjectZero\DomainModel\image\bkg.PNG");
}
}
}
控制器向视图发送以下内容:
public ActionResult Index()
{
BackgroundImage bkImg = new BackgroundImage();
return View(bkImg);
}
视图如下所示:
<p> Height: </p><%= Model.Image.Height //it prints the height of the image %> </br>
<p> Width: </p><%= Model.Image.Width //it prints the width %> </br>
<p> Image: </p><%= Model.Image //does not work to display the image %>
如何显示该图像属性?
我需要该背景图片作为 div。我不需要调整图像大小,我只需要以正常大小显示它。
有没有我想念的 Html Helper?
感谢您的宝贵时间!
【问题讨论】:
标签: asp.net-mvc image properties model