2017-03-11 1 views
0

J'ai ce code om my View. Et c'est un bon travail.Url.Action to Html.Raw

... onclick="location.href = '@Url.Action("Plan", "Care", new {Area = "HomeC"})'"><img src="~/Content/images/dash/Care.PNG" 

Comment faire le même code avec Html.Raw? J'ai essayé

grid.Column(columnName: "Name", header: "", format: @<text>@(item.ListStatus == 1 ? Html.Raw("<button class='btn btn-default btn-plan' title='Care' onclick='location.href = " + "'" + Url.Action("Plan", "Care", new {Area = "HomeC"}) + "''>" + 
                     "<img src='/Content/images/dash/Care.PNG' class='img-plan' data-interlocutorid=" + item.UserId + " " + "data-interlocutorname=" + item.Name + " " + ">" + 
                    "</button>") : Html.Raw("")) 
                   </text>), 

Avec l'image tout bon, mais le lien ne fonctionne pas.

+0

Qu'essayez-vous de faire? – Shyju

+0

Je modifie mon code. Regardez s'il vous plaît. –

Répondre

0
onclick=" + "location.href=" + "'" + Url.Action("Plan", "Care", new {Area = "HomeC"}) + "'" + ">" 

Ceci est un bon travail.

0

Modifiez plutôt les guillemets simples autour de votre Url.Action (...) en guillemets.

C'est, changer cette partie:

onclick='location.href = " + "'" + Url.Action("Plan", "Care", new {Area = "HomeC"}) + "'' 

à ceci:

onclick='location.href = " + "\"" + Url.Action("Plan", "Care", new {Area = "HomeC"}) + "\"' 

Cela changera la sortie rendu de:

onclick='location.href = '/Care/Plan?Area=HomeC'' 

à:

onclick='location.href = "/Care/Plan?Area=HomeC"'