SHARE
TWEET

Untitled

a guest Jan 18th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <%:Html.DropDownListFor(m=>m.FatherId,Model.father,new{id="drpFatherId",disabled="true"})%>
  2.  
  3. <%:Html.TextBoxFor(m => m.FatherName, new { id = "txtfatherName"})%><br />                    
  4.  
  5. <span style="color:Red;" id="Error"></span>
  6.    
  7. $("input#txtfatherName").change(function () {
  8.         //alert("message");
  9.         var term = $(this).val();
  10.         $.ajax(
  11.         {
  12.             url: 'Home/getFatherId',
  13.             type: 'POST',
  14.             data: { term: term },
  15.             dataType: 'json',
  16.             Success: function (data) {
  17.                 if (data != 0) {
  18.                     $("#drpFatherId").val(data);
  19.                     document.getElementById("Error").innerHTML = "";
  20.                 }
  21.                 else {
  22.                     $("#drpFatherId").val(0);
  23.                     document.getElementById("Error").innerHTML = "Our System does not recognize this father name. please try again.";
  24.                     $("#txtfatherName").focus();
  25.                 }
  26.             }
  27.         });
  28.     });
  29.    
  30. public JsonResult getFatherId(string term)
  31. {
  32.     int fatherId = 0;
  33.     using (ManageMembers mngMembrs = new ManageMembers())
  34.     {
  35.         Member data = mngMembrs.getFatherID(term);
  36.         if (data != null)
  37.             fatherId = data.ID;
  38.     }
  39.     return Json(fatherId, JsonRequestBehavior.AllowGet);
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top