<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中,它是一个reqular文本框我会这样做@ Html.textboxFor( model =&gt; model.Link)。但我不能做lamba表达式错误。
答案 0 :(得分:0)
嗨,下面的Actionlink将会对你有所帮助
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
}
}