![](/img/trans.png)
[英]How to pass the Value of particular field of parent View to Child View in MVC4?
[英]how to view single image with respect to particular ID value using MVC?
在我的代码中,已经查看了整个图像,但是我只需要显示特定的ID值图像即可。
<div class="photo">
@foreach (var imgPath in Directory.GetFiles(Server.MapPath("~/ComapnyLogo"), "*.png"))
{
var img = new FileInfo(imgPath);
<img src="@Url.Content(String.Format("~/ComapnyLogo/{0}", img.Name))" />
}
</div>
隐藏的ID
<input type="hidden" value="@ViewBag.hdnCompany" id="hdnCompany" />
public ActionResult ViewCompany()
{
var data = dp.Company.SqlQuery("Select * from CompanyRegistration").ToList();
return View(data);
}
小错误,我解决了问题
<img src="@Url.Content(String.Format("~/ComapnyLogo/" + MainModel.CompanyID + ".png"))" />
在这段代码中,我这边工作得很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.