This example illustrates how to add DockPanel to the view dynamically and restore their layout from cookies when view page is reloaded. We are using the approach from the How to use the jQuery.ajax function with DevExpress MVC Extensions code example to generate a new DockPanel on the server side and add its resulting HTML to the view page:
[JScript]$.ajax({ url: '@Url.Action("DockPanelPartial", "Home")', type: "POST", data: { index: count }, success: function(response){ $(response).appendTo('#ajaxDiv'); ASPxClientUtils.SetCookie("panelsCount", count + 1);}});
In addition, make a note of the code used to restore previously created DockPanels:
[C#]<divid="ajaxDiv">@* Restore old panels: *@@if(Request.Cookies["panelsCount"]!=null){intpanelsCount=Convert.ToInt32(Request.Cookies["panelsCount"].Value);for(inti= 0;i<panelsCount;i++){Html.RenderAction("DockPanelPartial","Home",new{index=i});}}</div>