How To Change or refresh data using ViewBag in MVC3

前端 未结 1 1636
独厮守ぢ
独厮守ぢ 2021-01-28 14:34

I want to refresh the data in the view using ViewBag. Is it possible or may i use some other technique....

Here is my sample Code

In My View Page

相关标签:
1条回答
  • 2021-01-28 15:15

    You don't reload a view. The browser sends a request which is handled by a controller which then creates the view model (in this case the viewbag) then selects a view to which the view model is passed on.

    You need to populate the view bag with the data you want in the controller. This is how an asp.net mvc application works.

    If you want to update the view via ajax, then you just use jquery to invoke another action which will return the data you want as json or html, which it'll be inserted by the javascript. But in this case, the controller just returns a json result.

    I think you really need to learn about asp.net mvc. The official site has basic tutorials http://www.asp.net/mvc/tutorials .

    0 讨论(0)
提交回复
热议问题