アプリケーションの上部にサーバステータスアイコンを作成しようとしています。オフになっているときは赤で表示され、反対にあるときは緑で表示されます。MVC htmlステータスインジケータのカスタムヘルパー
私はDAL、BL、Controller、ViewModelですべてのダーティージョブを実行しました。その結果、私のページにサービスステータスの影響を受ける色を変更するdiv要素があります。私の問題は、私はdivの隣にラベルを追加できないということです。
public static class ServerStatusIconHelper
{
public static MvcHtmlString ServerStatusIconHelper(this HtmlHelper htmlHelper, bool isServerActive)
{
// Main container
var div = new TagBuilder("div");
bool isActive = isServerActive;
var labelValue = isActive ? "The server status is On" : "The server status is Off";
if (isActive)
{
div.Attributes.Add("id", "server-warning-on");
div.Attributes.Add("style", "background-color: green; height:25px; margin-bottom: 10px; border-radius: 25px; width: 25px; margin-left: 10px;");
}
else
{
div.Attributes.Add("id", "server-warning-off");
div.Attributes.Add("style", "background-color: red; height:25px; margin-bottom: 10px; border-radius: 25px; width: 25px; margin-left: 10px;");
}
return new MvcHtmlString(div.ToString());
}
}
私はlabelValue
を提供します段落要素とdiv要素を追加することを知らないので、私はいくつかの助けをいただければ幸いです。さらに、誰かが何か良いアイデアを持っていれば、よかったです。
あなたはdivのための任意の内部テキストまたは内部HTMLを設定しませんでした。 –