0

Here i am using anchor tag for this class is not applying.And this is my code

 <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>  

Previously i used

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

but iam getting error for second one

Arun Raju
  • 139
  • 2
  • 15

1 Answers1

1

You're going about this wrong. You're getting mixed up with 'normal' HTML, and helpers.

You don't pass in your @class attributes to the anonymous object passed to Url.Action

Just use normal HTML in conjunction with Url.Action if you want: You're going about this wrong. You're getting mixed up with 'normal' HTML, and helpers.

You don't pass in your @class attributes to the anonymous object passed to Url.Action

Just use normal HTML in conjunction with Url.Action if you want:

 <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>  

You could use Html.ActionLink as described 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
                )
Community
  • 1
  • 1
Alex
  • 37,502
  • 51
  • 204
  • 332
  • are you sure you copy/pasted correctly - there's a space in your url you posted above (%20ViewServiceDetails) – Alex May 17 '17 at 15:23