禁用MVC4中的下拉控件 [英] Disable the dropdown controls in MVC4

查看:54
本文介绍了禁用MVC4中的下拉控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个这样的场景,我必须禁用一些控件,包括基于标准的下拉列表。

如果一个单选按钮收音机是检查并单击提交按钮时,控件应被禁用。它最大程度地工作。但是有时候单击提交按钮时页面会刷新并且控件正在显示并且页面刷新消失。页面刷新有时只会发生。

这是提交按钮点击的代码。

$(#SearchBtn')。click(function(){

$(' #DivSlNo')。hide();

var chkVal = $('input [name = SearchBy]:checked')。val();

if(chkVal = ='ShowAll'){

$('#DivSlNo')。hide();

$('#DivCriteria')。hide();

$('#DivECSId')。hide();

}

});





请帮忙解决这个问题?



我尝试过:



通过以下方式尝试禁用单个元素和div元素。

$('#DivECSId')。attr('禁用','禁用');

$('#DivECSId')。hide();

$('#tdSearchFields:input')。attr('disabled',true);

$(#tdSearchFields)。find(input,button,textarea,select)。attr (禁用,真实);



但是没有什么对我有用。

Hi,
I have a such scenario where I have to disable some of the controls including the dropdown based on a criteria.
If one of radio button radio is checked and when clicking on submit button the controls should be disabled.Its working for a maximum extent.But some times the page is getting refreshed when clicking on submit button and the controls are appearing and disappearing the page refresh.The page refresh happens only sometimes.
Here is the code for submit button click.
$(#SearchBtn').click(function () {
$('#DivSlNo').hide();
var chkVal = $('input[name=SearchBy]:checked').val();
if (chkVal == 'ShowAll') {
$('#DivSlNo').hide();
$('#DivCriteria').hide();
$('#DivECSId').hide();
}
});


Please help how to overcome this issue?

What I have tried:

Tried in the following way to disable the individual elements and div elements.
$('#DivECSId').attr('disabled', 'disabled');
$('#DivECSId').hide();
$('#tdSearchFields :input').attr('disabled', true);
$("#tdSearchFields").find("input,button,textarea,select").attr("disabled", true);

But nothing works for me.

推荐答案

(#SearchBtn')。click(function() {
(#SearchBtn').click(function () {


('#DivSlNo')。hide();

var chkVal =
('#DivSlNo').hide();
var chkVal =


( 'input [name = SearchBy]:checked')。val();

if(chkVal =='ShowAll'){
('input[name=SearchBy]:checked').val();
if (chkVal == 'ShowAll') {


这篇关于禁用MVC4中的下拉控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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