2017-05-17 65 views
0

我在這裏使用錨標記此類不applying.And這是我的代碼類沒有申請鏈接

<td> <a href="@Url.Action("ViewServiceDetails", "ServiceConsumer", new { BookingID = CAH.BookingID, @class = "btn btn-link", data_toggle = "modal", data_target = "#ViewServiceDetails" })">@CAH.BookingID</a></td> 

以前我使用

<td> @Html.ActionLink((string)CAH.BookingID, "ViewServiceDetails", "ServiceConsumer", new { BookingID = CAH.BookingID }, new { @class = "btn btn-link", data_toggle = "modal", data_target = "#ViewServiceDetails" })</td> 

但對於第二IAM越來越錯誤一個

+0

使用'Html.ActionLink' – User3250

+0

「這個類是不適用」什麼班?你在問什麼?! – Alex

+0

@Alex類,我創造了desing即@ class =「btn btn-link」 –

回答

1

你正在談論這個錯誤。 你正在混淆'普通'的HTML和助手。

你不要在你的@class將屬性傳遞給Url.Action

只需使用普通的HTML與Url.Action結合,如果你想匿名對象: 你要對這個錯誤的。 你正在混淆'普通'的HTML和助手。

你不要在你的@class將屬性傳遞給Url.Action

匿名對象

只是結合,如果你想使用普通的HTML與Url.Action

<td> 
    <a href="@Url.Action("ViewServiceDetails", "ServiceConsumer", new { BookingID = CAH.BookingID })" 
     class="btn btn-link" 
     data-toggle="modal" 
     data-target="#ViewServiceDetails"> 
     @CAH.BookingID  
    </a> 
</td> 

你可以使用Html.ActionLink如上所述here

@Html.ActionLink(CAH.BookingID, // <-- Text of link. 
       "ServiceConsumer", // <-- Controller Name. 
       "ViewServiceDetails", // <-- ActionMethod 
       new { BookingID = CAH.BookingID }, // <-- Route arguments. 
       new { @class="btn btn-link", data_toggle = "modal", data_target = "#ViewServiceDetails" } // <-- htmlArguments 
       ) 
+0

你確定你複製/粘貼正確 - 你的網址上面有一個空格(%20ViewServiceDetails) – Alex

+1

它的工作謝謝你 –