Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my code is

C#
string reg2 = @"^[0-9a-zA-Z/-]+$";
               var expr1 = new Regex(reg2);
               if (reg_no !="" && !expr1.IsMatch(reg_no))
               {
                   return Json("Please Enter Correct Registration Number !", JsonRequestBehavior.AllowGet);
               }


here i want that return Json value should come in Label control , how cam i do this plz help me
Posted

1 solution

Call a JS and using Ajax Callback, it can be achieved.
In below example, Call a function SelectCity, in this function we call a Action in controller that returns string value. We have a callback function here also when return then it go to callback function and we set the value in label.

JavaScript
function SelectCity(id) {
    var cityid = $('#' + id).val();
    $.ajax({ type: "POST", data: JSON.stringify({ CityId: cityid }), async: true, url: "/Enrolment/SateandPinCode", dataType: "json", contentType: "application/json; charset=utf-8", success: GetSateandPinCode });
}

JavaScript
function GetSateandPinCode(JO) {
    if (JO.length > 0) {
        $('#lblProposerState_' + 1).val(JO[0].BOStateName);
        // $('#lblProposerPin_' + 1).val(JO[0].BOPinCode);
    }
}


Use this, it will help you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900