<div class="form-group">
@Html.LabelFor(model => model.Link, htmlAttributes: new { @class = "control-label col-md-3" })
<div class="col-md-9">
@Html.ActionLink("View", "Viewer", "Drawings", new { filePath = ....... }, new { target="_blank"})
</div>
</div>我是mvc新手,这里的@model.Link有文件名,我的困惑是如何将模型值放在filePath中,它是一个规模化文本框,我会这样做的-- @Html.textboxFor(model=> model.Link)。但是我不能做lamba表达式得到一个错误。
发布于 2017-06-28 01:28:30
嗨,下面是一个动作链接的速度将对你有帮助。
public static MvcHtmlString ActionLink(
this HtmlHelper htmlHelper,
string linkText,
string actionName,
object routeValues,
object htmlAttributes
)您的示例:
<div class="form-group">
@Html.LabelFor(model => model.Link, htmlAttributes: new { @class = "control-label col-md-3" })
<div class="col-md-9">
@Html.ActionLink("View", "Viewer", "Drawings", new { filePath = Model.Link ,filename = Model.fileName ,...etc }, new { target="_blank"})
</div>
</div>您的控制器操作方法看起来将得到以下值:
public class ViewerController:Controller
{
public ActionResult view(string filepath,string filename) //datatype may vary according to the model
{
//your action logic
}
}https://stackoverflow.com/questions/44790540
复制相似问题