MVCビューのテキスト内に2つのリンクを持つテキストを表示したいと思います! テキストリンクは、サーバ側から動的であり、コントローラで次のようになります。ビューでmvcビューの変数をhtml属性クラスを持つようにrazorで宣言する方法
Model.Message = "You have used up all your credits for this month (see your credit balance {FirstLink}). You can buy credits {SecondLink}";
私はこれはそれのようにされて働いているが、私はクラスを追加する必要があり、この
@{
var messageToShow = @Model.Message;
var newText = Html.ActionLink(Model.LinkText, Model.LinkAction, Model.LinkController, Model.LinkRouteValues).ToString();
var link = Html.ActionLink(Model.SecondLinkText, Model.SecondLinkAction, Model.SecondLinkController, Model.LinkRouteValues).ToString();
}
@if (!string.IsNullOrEmpty(Model.LinkText))
{
messageToShow = messageToShow.Replace("{FirstLink}", newText);
}
@if (!string.IsNullOrEmpty(Model.SecondLinkText))
{
messageToShow = messageToShow.Replace("{SecondLink}", link);
}[![enter image description here][1]][1]
@Html.Raw(messageToShow)
のようなものを持っています閉鎖}がひどくカミソリエンジンによって解釈されているので、新しい{@class =「リンク」}追加する場合、この
@Html.ActionLink(Model.SecondLinkText, Model.SecondLinkAction, Model.SecondLinkController, Model.LinkRouteValues, new { @class = "link" })
等これに私は、構文エラーが発生しました。
より良い解決法をお手伝いすることができますか?
おかげ