私が "正しく"検索したかどうかわからない前に、私は何を説明し、何も書いていないのに何も書いていないのですが、htmlヘルパーを使う必要があるからです。
私がしようとしているのは、ccs3カスタムチェックボックスを作成することです。私は複数のデザインが見つかりました。私はちょうどそれらに従いましたが、私はHtml.CheckBoxFor(..., htmlAttributes: new { id = "A Number"})
を使用しています。 "A Number"はループを投げた単なる数字です。私は手作業ではしません。.net mvc htmlヘルパーでcss3を使用
私はHTMLヘルパーcheckboxforを使用して、私はそれを使用する場合は、この方法は、それは文句を言わない私がなぜわからないか、私はそれについてだけで混乱しています作業する場合、これは私がカスタムチェックボックスを処理する方法(1)
<p>
<input type="checkbox" value="..." id="@count" />
<label for="@count"><span class="ui"></span>Name</label>
</p>
です。 (2)今
<p>
@Html.CheckBoxFor(m => m..., htmlAttributes: new { id = count })
<label for="@count"><span class="ui"></span>...</label>
</p>
私は(2)最初の時間は、それが動作しませんでしたし、私はそれが私からだと思ったが、私が試したとき、(1)それは不思議は私が提出したときにそれはdoesnのことを期待して働いてみましたチェックボックスの値を返します。私が検索したときに私はこれを見つけたAddind css classes to razor elementsからの応答darin-dimitrovは面白かったですが、私は私の見解ではLayout = "..."
でそれを単に呼び出すカスタムテンプレートを使用します。答えのこの部分は私のためにflouです私はどのように私はこれを宣言するか、私はどのように呼び出すか、それが一意であるか、またはすべてを変更するかわかりません。
@Html.TextBox( "", ViewData.TemplateInfo.FormattedModelValue, ViewData )
CSS3のコード
/*
Custom Checkboxes
*/
[type="checkbox"]:not(:checked),
input[type="checkbox"]:checked {
position: absolute;
left: -9999px;
}
[type="checkbox"]:not(:checked) + label,
[type="checkbox"]:checked + label {
position: relative;
padding-left: 75px;
cursor: pointer;
}
[type="checkbox"]:not(:checked) + label:before,
[type="checkbox"]:checked + label:before,
[type="checkbox"]:not(:checked) + label:after,
[type="checkbox"]:checked + label:after {
content: '';
position: absolute;
}
[type="checkbox"]:not(:checked) + label:before,
[type="checkbox"]:checked + label:before {
left:0; top: -3px;
width: 65px; height: 30px;
background: #DDDDDD;
border-radius: 15px;
-webkit-transition: background-color .2s;
-moz-transition: background-color .2s;
-ms-transition: background-color .2s;
transition: background-color .2s;
}
[type="checkbox"]:not(:checked) + label:after,
[type="checkbox"]:checked + label:after {
width: 20px; height: 20px;
-webkit-transition: all .2s;
-moz-transition: all .2s;
-ms-transition: all .2s;
transition: all .2s;
border-radius: 50%;
background: #7F8C9A;
top: 2px; left: 5px;
}
/* on checked */
[type="checkbox"]:checked + label:before {
background:#34495E;
}
[type="checkbox"]:checked + label:after {
background: #39D2B4;
top: 2px; left: 40px;
}
[type="checkbox"]:checked + label .ui,
[type="checkbox"]:not(:checked) + label .ui:before,
[type="checkbox"]:checked + label .ui:after {
position: absolute;
left: 6px;
width: 65px;
border-radius: 15px;
font-size: 16px;
font-weight: bold;
line-height: 22px;
-webkit-transition: all .2s;
-moz-transition: all .2s;
-ms-transition: all .2s;
transition: all .2s;
}
[type="checkbox"]:not(:checked) + label .ui:before {
content: "non";
left: 32px
}
[type="checkbox"]:checked + label .ui:after {
content: "oui";
color: #39D2B4;
}
[type="checkbox"]:focus + label:before {
border: 1px dashed #777;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
margin-top: -1px;
UPDATE
ビュー
@model WebAppWithEF.Models.MainModel
@using WebAppWithEF.Models;
@{
ViewBag.Title = "Page Title";
Layout = "~/Views/Shared/_TemplateRest.cshtml";
}
@using (Html.BeginForm(null, "Export", new { entity_name = Model.which_entity_to_show }, FormMethod.Post, null))
{
<div>
<span class="text-uppercase">Nom Définition </span>
@Html.EditorFor(m => m.exportDefinition.name, new { htmlAttributes = new { maxlength = "50" } }) <br />
@if (Model.is_any_checked == false)
{
@Html.Label("Error MSG", htmlAttributes: new { @class = "text-danger" }) <br/>
}
<br />
@for (int count = 0; count < Model.selectedFields.Count(); count++)
{
<p>
@Html.CustomCheckBoxFor(m => m.selectedFields[count].propertyStatus)
@Html.CustomLabelFor(m => m.selectedFields[count].propertyStatus, Model.selectedFields[count].propertyName, "<span class=\"ui\"></span>", new { @class = "class" })
</p>
@Html.HiddenFor(m => m.selectedFields[count].propertyStatus)
@Html.HiddenFor(m => m.selectedFields[count].propertyName)
}
@Html.HiddenFor(m => m.exportDefinition.pkey)
@Html.HiddenFor(m => m.exportDefinition.entityID)
<div class="col-md-offset-0 col-md-10">
<div class="contact-button">
<button name="SaveDefinition" onclick="submit()">Enregistrer/Modifier</button>
</div>
</div>
<div class="col-md-offset-0 col-md-10">
<div class="contact-button">
<button name="SpecificExport" onclick="submit()">Exporter</button>
</div>
</div>
@if (!Model.is_new)
{
<div class="col-md-offset-0 col-md-10">
<div class="contact-button">
<button name="DeleteDefinition" onclick="submit()">Supprimer</button>
</div>
</div>
}
<div class="col-md-offset-0 col-md-10">
<div class="contact-button">
<button onclick="@Url.Action("Index", "Home" , new { entity_name = ViewBag.entity_name })">Retour</button>
</div>
</div>
</div>
}
はいプロパティstatusはdbの値に依存します(プロジェクトは機能が賢明ですが、私がそれをテストしたことを知っていると思っていました。 –
私の答えの更新を確認してください – mihkov
私は私と一緒にしたように人々を助けることができますが、私は自分自身を新鮮だと思う。 –