بهار آموزش با تخفیف های شگفت انگیز توسینسو بهار آموزش با تخفیف های شگفت انگیز توسینسو
مانده تا پایان تخفیف
مشاهده دوره ها
0

عدم نمایش تیک cheackbox در asp.net mvc

سلام دوستان عزیزم خسته نباشید ،

من یک cheackbox دارم که checked رو نمی گیره وقتی که inspect element میزنم چرا؟! یعنی می خوام cheackbox تیک بخوره ولی نمیشه!

این کد سی شار پ :

   <p>
                       @{
                           var testDisable = (byte)GeneralStat.Disable;
                           var testEnable = (byte)GeneralStat.Enable;
                           }
                       <input type="radio" class="flat-red" name="DebugMode"  value="@((byte)GeneralStat.Disable)" @(Model.DebugMode == (byte)GeneralStat.Disable ? "checked" : "") />
                       @*<input type="radio"  name="DebugMode" value="@((byte)GeneralStat.Disable)" @(Model.DebugMode == (byte)GeneralStat.Disable ? "checked" : "") />*@
                       <label style="display: inline-block;"> غیرفعال</label>
                       &nbsp &nbsp<br />
                        <input type="radio" class="flat-red" name="DebugMode" value="@((byte)GeneralStat.Enable)" @(Model.DebugMode == (byte)GeneralStat.Enable ? "checked" : "") />
                       @*<input type="radio"  name="DebugMode" value="@((byte)GeneralStat.Enable)" @(Model.DebugMode == (byte)GeneralStat.Enable ? "checked" : "") />*@
                       <label style="display: inline-block;">فعال</label>
                    </p> 

اینم کد html تولیدی در inspect element :

<p>

                       <div class="iradio_flat-red" aria-checked="false" aria-disabled="false" style="position: relative;"><input type="radio" class="flat-red" name="DebugMode" value="0" style="position: absolute; opacity: 0;"><ins class="iCheck-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; border: 0px; opacity: 0; background: rgb(255, 255, 255);"></ins></div>
                       
                       <label style="display: inline-block;"> غیرفعال</label>
                       &nbsp; &nbsp;<br>
                        <div class="iradio_flat-red" aria-checked="false" aria-disabled="false" style="position: relative;"><input type="radio" class="flat-red" name="DebugMode" value="1" checked="" style="position: absolute; opacity: 0;"><ins class="iCheck-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; border: 0px; opacity: 0; background: rgb(255, 255, 255);"></ins></div>
                       
                       <label style="display: inline-block;">فعال</label>
                    </p>
پرسیده شده در 1395/06/06 توسط

4 پاسخ

0

این کد GeneralStat :

using System;
using System.ComponentModel;

namespace Sms.Core
{
    public enum GeneralStat
    {
        [Description("غیر فعال")]
        Disable = 0,
        [Description("فعال")]
        Enable = 1,
    }
}

مقدار testDisable=0 و testEnable=1 هست موقع debug کردن و Model.DebugMode=1 هست پس در هر صورت باید یکی از cheackbox ها تیک بخوره.

پاسخ در 1395/06/06 توسط
0

مقدار Disabled رو هم چک کردید؟ اگه Disabled از یک enum باشه و آیتم اول، مقدارش 0 هست، یه بررسی کنید ببینید شرطی که نوشتید True میشه یا نه.

پاسخ در 1395/06/06 توسط
0

سلام، چک کنید ببینید مقدار DebugMode برابر true هست یا نه. فکر کنم مشکل از مقدار DebugMode داخل Model باشه.

پاسخ در 1395/06/06 توسط

پاسخ شما