使用Jquery在MVC4中禁用复选框时传递NULL值。 [英] Passing NULL value while disable the checkbox in MVC4 using Jquery.

查看:57
本文介绍了使用Jquery在MVC4中禁用复选框时传递NULL值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已在下面解释了我的房产问题。



数据库



我维护了SpInsertUpdateUsers这些是参数(userID,UserName,.. IsEtaTech)





i维持如果IsETATech的值为Null / False那么它将更新值为false



工作正常。



现在来查看



在视图中我保持了



IsETATech:{

title:'ETA Tech ',

类型:'复选框',

值:{'false':'无效','真':'有效'},

defaultValue:'false',

list:false

}



此属性维护数据库值当我试图从数据库中获取具有显示准确值的数据时(即是对还是错。)



案例1:我想为某些用户禁用复选框,因为我保留了以下功能



函数GetIsTeamActiveStatus(teamId)

{

var userrole = @ HttpContext.Current.Session [RoleId];



if((userrole!=1)&&(userrole!=3))

{



$('#Edit-IsETATech')。prop('disabled',true);

$('#Edit-IsETATech')。兄弟姐妹( )[0] .disabled = true;

}



}



这也工作正常,但主要的问题是,当我想更新记录时,IsETATech属性传递空值,因为用户标志更改为false。下一次用户因为null而丢失了True标志改变为假。



所以你可以帮我解决这个问题,或者给我任何建议来解决这个问题。

I have explained my property problem in the below.

Database

I have maintained SpInsertUpdateUsers these are the parameters(userID,UserName,..IsEtaTech)


i have maintained that If IsETATech has value Null/False then it will be Updated value as false"

it is working fine.

Now coming to View

In view i have maintained

IsETATech: {
title: 'ETA Tech',
type: 'checkbox',
values: { 'false': 'Inactive', 'true': 'Active' },
defaultValue: 'false',
list: false
}

this property has maintain database value when i tried to fetch the data from db that has display accurate value(ie True or False).

Case 1: I want to disable checkbox for some users for that i have maintained the below function

function GetIsTeamActiveStatus(teamId)
{
var userrole= @HttpContext.Current.Session["RoleId"];

if ((userrole!="1") && (userrole!="3"))
{

$('#Edit-IsETATech').prop('disabled', true);
$('#Edit-IsETATech').siblings()[0].disabled=true;
}

}

This is also working fine but the Main problem is when i want to update the record the "IsETATech" property is passing null value because of that the user flag changed as false.Next time user has lost "True" flag because of null it as changed as false.

So could you please help me for this any other logic is there or give me any suggestion to resolve this.

推荐答案

('#Edit-IsETATech')。prop('disabled',true);
('#Edit-IsETATech').prop('disabled', true);


('#Edit-IsETATech' ).siblings()[0] .disabled = TRUE;
}



}



这也工作正常但主要问题当我想要更新记录时,IsETATech属性传递空值,因为用户标志更改为false。下一次用户丢失了True标志因为null将其更改为false。



那么请你帮我解决这个问题,或者给我任何建议来解决这个问题。
('#Edit-IsETATech').siblings()[0].disabled=true;
}

}

This is also working fine but the Main problem is when i want to update the record the "IsETATech" property is passing null value because of that the user flag changed as false.Next time user has lost "True" flag because of null it as changed as false.

So could you please help me for this any other logic is there or give me any suggestion to resolve this.


这篇关于使用Jquery在MVC4中禁用复选框时传递NULL值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆