2017-06-27 13 views
0
 <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 => model.Link)をやっただろう。しかし、私はエラーを得るlambaの表現を行うことはできません。パラメータを持つ@HtmlActionLinkにルーティング値を入力

+2

'new {filePath = Model.Link}' –

答えて

0

ActionLinkののoveload以下こんにちは、あなた

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 

    } 

} 
関連する問題