1. I have 4 text boxes and one button in my view page in asp.net with c# and MVC. 2. now, on pressing TAB key in first text box, I am calling Stored procedure from a controller and getting Value from one table and displaying that value in second text box.. 3. I am doing it using Java script or jquery ...using <http post>.. But Http Post is going to controller only when the page is loaded for the first time.... 4. If i Press TAB key for the second time , the page is not posting and Http Post is not firing. Please Help....Thanks in advance
@model Mvc4App10.Models.Loan_Account @{ ViewBag.Title = "Register_Loan_Account"; } @{ var message = TempData["AlertMessage"] ?? string.Empty; } <script src="../../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script> <script src="../../Scripts/jquery.unobtrusive-ajax.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { $('#EMPID').change(function () { $.ajaxSetup({ // Disable caching of AJAX responses cache: false; }); $('form').submit(); }); }); </script> <h2>Register_Loan_Account</h2> @using (Html.BeginForm()) { @Html.ValidationSummary(true) <fieldset> <div class="Editor-label"> @Html.LabelFor(model=>model.EMPID) </div> <div class="Editor-field"> <p> @Html.TextBoxFor(model => model.EMPID, ViewBag.FilterValue as string)</p> <--clicking Tab key...values from other table is taken using stored procedure from controller and that value is displayed in textbox 'LAmount' --> @Html.ValidationMessageFor(model=>model.EMPID) </div> <div class="Editor-label"> @Html.LabelFor(model=>model.Rate) </div> <div class="Editor-field"> @Html.TextBoxFor(model => model.Rate, ViewBag.FilterValue as string) @Html.ValidationMessageFor(model=>model.Rate) </div> <div class="Editor-label"> @Html.LabelFor(model=>model.LAmount) </div> <div class="Editor-field"> @*@Html.TextBoxFor(model => model.LAmount, ViewBag.FilterValue as string, new { Value = ViewData["Empid"] })*@ @Html.TextBoxFor(model => model.LAmount, ViewBag.FilterValue as string) @Html.ValidationMessageFor(model => model.LAmount) </div> <div class="Editor-label"> @Html.LabelFor(model=>model.Balance) </div> <div class="Editor-field"> @Html.TextBoxFor(model => model.Balance, ViewBag.FilterValue as string) @Html.ValidationMessageFor(model=>model.Balance) </div> <div class="Editor-label"> @Html.LabelFor(model=>model.Remarks) </div> <div class="Editor-field"> @Html.TextBoxFor(model => model.Remarks, ViewBag.FilterValue as string) @Html.ValidationMessageFor(model=>model.Remarks) </div> <p> <input type="submit" value="Register" /> </p> </fieldset> <div> @Html.ActionLink("Back to Index","IndexManualGrid") </div> }
[HttpPost] public ActionResult Register_Loan_Account(Loan_Account Loan1) { //code....everything is working fine when the page is loaded for the first time....its calling jquery only for the first time...but after then its not coming to controller...plz help }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)