Last active
July 13, 2017 14:06
-
-
Save mahmut-gundogdu/172401b0e75ad7dc7e6e6a1a022adb6d to your computer and use it in GitHub Desktop.
Kullanıdığım tasarımda bool ve bazı int değerleri Evet Hayır radiobutton ile belirli bir formatta göstermek istiyordum. göstermek istiyordum. ancak model dynamic olunca farklı cozum almam gerekti. Yazım: https://mahmutgundogdu.wordpress.com/2017/07/13/asp-net-mvc-editor-template-ile-custom-radio-button-group-yapimi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@model dynamic | |
@if (Model is bool || Model is bool?) | |
{ | |
<div class="mt-radio-inline"> | |
<label class="mt-radio mt-radio-outline"> | |
Evet | |
@Html.RadioButtonFor(model => model, true, ViewData["HtmlAttributes"], (bool?)Model == true) | |
<span></span> | |
</label> | |
<label class="mt-radio mt-radio-outline"> | |
Hayır | |
@Html.RadioButtonFor(model => model, false, ViewData["HtmlAttributes"], (bool?)Model == false) | |
<span></span> | |
</label> | |
</div> | |
} | |
else | |
{ | |
<div class="mt-radio-inline"> | |
<label class="mt-radio mt-radio-outline"> | |
Evet | |
@Html.RadioButtonFor(model => model, 1, ViewData["HtmlAttributes"]) | |
<span></span> | |
</label> | |
<label class="mt-radio mt-radio-outline"> | |
Hayır | |
@Html.RadioButtonFor(model => model, 0, ViewData["HtmlAttributes"]) | |
<span></span> | |
</label> | |
</div> | |
} | |
@Html.ValidationMessageFor(model => model, "", new { @class = "text-danger" }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@model bool? | |
<div class="mt-radio-inline"> | |
<label class="mt-radio mt-radio-outline"> | |
Evet | |
@Html.RadioButtonFor(model => model, true, ViewData["HtmlAttributes"]) | |
<span></span> | |
</label> | |
<label class="mt-radio mt-radio-outline"> | |
Hayır | |
@Html.RadioButtonFor(model => model, false, ViewData["HtmlAttributes"]) | |
<span></span> | |
</label> | |
</div> | |
@Html.ValidationMessageFor(model => model, "", new { @class = "text-danger" }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment