Asp.net mvc 使用参数将路由值放入@HtmlActionLink @LabelFor(model=>model.Link,htmlAttributes:new{@class=“controllabel col-md-3”}) @ActionLink(“视图”、“查看器”、“绘图”、新的{filePath=…..}、新的{target=“\u blank”})
我是mvc新手,这里@model.Link有文件名,我的困惑是如何将模型值放在filePath中,这是一个需要的文本框,我会这样做@Html.textboxFor(model=>model.Link)。但是我不能让lamba表达式出错。您好,下载Actionlink将对您有所帮助Asp.net mvc 使用参数将路由值放入@HtmlActionLink @LabelFor(model=>model.Link,htmlAttributes:new{@class=“controllabel col-md-3”}) @ActionLink(“视图”、“查看器”、“绘图”、新的{filePath=…..}、新的{target=“\u blank”}),asp.net-mvc,razor,Asp.net Mvc,Razor,我是mvc新手,这里@model.Link有文件名,我的困惑是如何将模型值放在filePath中,这是一个需要的文本框,我会这样做@Html.textboxFor(model=>model.Link)。但是我不能让lamba表达式出错。您好,下载Actionlink将对您有所帮助 <div class="form-group"> @Html.LabelFor(model => model.Link, htmlAttributes: new
<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>
您的示例:
public static MvcHtmlString ActionLink(
this HtmlHelper htmlHelper,
string linkText,
string actionName,
object routeValues,
object htmlAttributes
)
new{filePath=Model.Link}
<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
}
}