でクラスからCSHTML上の文字列をレンダリングします私はこのような公共のクラス持つ定数
namespace MyProgram.Common
{
public static class UIStrings
{
public const string Title = "Hellow World"
public const string SubTitle = "This is another string. Please click on '<a href=\"/Home/Status\" target=\"_blank">Here</a>'"
}
}
をそして、私のIndex.csthmlに、私は次のコードを持っている:
<label id="title" for="MyTitle">@Myprogram.Common.UiStrings.Title </label>
<label id="title" for="SubTitle">@Myprogram.Common.UiStrings.SubTitle </label>
タイトルはうまくレンダリングされますが、私が字幕で定義したリンクはリンクとしてではなく文字列としてレンダリングされます。
これを行う方法はありますか?私はcshtmlファイル内の文字列をハードコードすることを避けたいと思います...
それは魅力的に機能しました! – user3587624