“UpdatePanel” in Razor (mvc 3)

前端 未结 5 450
栀梦
栀梦 2020-12-14 12:06

Is there something like UpdatePanel (in ASPX) for Razor?

I want to refresh data (e.g. table, chart, ...) automaticly every 30 seconds. Similar to clicking the follow

5条回答
  •  被撕碎了的回忆
    2020-12-14 12:26

    If someone wants the complete code for a selfupdating partial view have a look!

    Code of the Controller:

    [HttpPost]
    public ActionResult RefreshSelfUpdatingPartial() {
    
                // Setting the Models Content
                // ...
    
                return PartialView("_SelfUpdatingPartial", model);
    }
    

    Code of the Partial (_SelfUpdatingPartial.cshtml):

    @model YourModelClass
    
    
    // Div
    
    // Link to Refresh per Click

    @Ajax.ActionLink("Aktualisieren", "RefreshFlatschels", new AjaxOptions() { UpdateTargetId = "FlatschelList", HttpMethod = "Post", InsertionMode = InsertionMode.Replace })

    // Your Code // ...

    Code to integrate the Partial in the "Main"-View (ViewWithSelfupdatingPartial.cs):

     @Html.Partial("_FlatschelOverview", Model)
    

提交回复
热议问题