asp.net mvc - how to pass 'true'/'false' data from Controller to View using jquery for bootstrap validator in MVC -
view
$('#frmcreatenewadminpanelmenu').bootstrapvalidator({ message: '.......', feedbackicons: { valid: 'glyphicon glyphicon-ok', invalid: 'glyphicon glyphicon-remove', validating: 'glyphicon glyphicon-refresh' }, fields: { txtmenuname_create: { validators: { notempty: { message: '......' }, stringlength: { min: 6, max: 100, message: '.......' }, remote: { type: 'post', url: '/adminpanelmenu/menunameremote', message: 'menu name not available.', delay: 1000 } } } } });
at bootstrapvalidator, txtmenuname_create passed checking whether there or not.
controller
public jsonresult menunameremote(string txtmenuname_create) { list<adminpanelmenu> adminmenus = _adminpanelmenurepo.getall().tolist(); return json(adminmenus.any(x => x.name.tolowerinvariant().trim() == txtmenuname_create.tolowerinvariant().trim()), jsonrequestbehavior.allowget); }
at controller, after txtmenuname_create checked, true or false data returned. but, don't know how pass data controller view.
i solved this.
public jsonresult menunameremote(string txtmenunameremote) { list<adminpanelmenu> adminmenus = _adminpanelmenurepo.getall().tolist(); if (adminmenus.any(x => x.name.tolowerinvariant().trim() == txtmenunameremote.tolowerinvariant().trim())) return json(new { valid = false }); else return json(new { valid = true }); }
Comments
Post a Comment