2 Replies - 557 Views - Last Post: 25 May 2018 - 01:44 PM Rate Topic: -----

#1 ahmed707   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 95
  • Joined: 30-January 15

current view page not refreshed

Posted 24 May 2018 - 07:12 PM

Hello bro

i hope All Okey

i have this button
   <button id="Total"  style="background-color: #2980b9">
          

                <h4>Total Students</h4>

                

            </button>



this is java script query

           $("#Total").click(function () {
                    debugger;

                    alert("ok");
                    var Ter = $("#TermId option:selected").text();
                    $.ajax({
                        @*url: '@Url.Action("List", "StudentInfo")',*@
                        url: '@Url.Action("GetTotalStudents", "TrainingInfo")',
                        type: "POST",
                        data: { TermCode: Ter },
                        success: function (data) {

                         
                  
                        }
                });

                });



this is action

 public ActionResult GetTotalStudents(string TermCode)
        {
       

           var  TotalStudentList =  from x in db.Students where x.StudentIdcard.StartsWith(TermCode)  select x;


           TempData["TotalStudList"] = TotalStudentList.ToList();

         
            return RedirectToAction ("Listt", "StudentInfo", TotalStudentList.ToList()); 

        }





this previous action call next action to view data

     [HttpGet]
        public ActionResult Listt()
        {
            var st = TempData["TotalStudList"];
            //return PartialView (st);
            return PartialView(st);
        }





i already traced the execution and model moved well to the last action but the problem is that current view not refreshed to Listt View

any help will be appreciated


thanks

This post has been edited by ahmed707: 24 May 2018 - 07:24 PM


Is This A Good Question/Topic? 0
  • +

Replies To: current view page not refreshed

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14776
  • View blog
  • Posts: 59,069
  • Joined: 12-June 08

Re: current view page not refreshed

Posted 25 May 2018 - 08:07 AM

Is this ASP.NET MVC? Core2?

Why would you be using AJAX calls if you are going to redirect the page anyways?
Was This Post Helpful? 0
  • +
  • -

#3 andrewsw   User is offline

  • Stealth IT
  • member icon

Reputation: 6700
  • View blog
  • Posts: 27,542
  • Joined: 12-December 12

Re: current view page not refreshed

Posted 25 May 2018 - 01:44 PM

The redirect is odd, but also is attempting to return a partial view from an Ajax request. It won't automatically be rendered on the page: where would it go?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1