c# - Pass dictionary of data to MVC view from controller "synchronously" -



c# - Pass dictionary of data to MVC view from controller "synchronously" -

my view show results multiple cases, have 3 type of results panel

and each result should show items match result panel type

i create partial view display each 1 item make loop display items in each result panel a view 3 result panel each panel - coded html div - have partial view sub items

what i'm thinking find away pass dictionary type string key , list of items - list - , in each partial command phone call pass dictionary item kind of panel like

<%= html.partial("mypartialcontrol",mydictionary["kindofpanel"] %>

so how pass dictionary view synchronously? there thought issue specially hole view should refreshed each 5 sec ! doing json or ajaxing solution.

the word asynchronously.

if want update portion of page without reloading whole page, done asynchronously ajax.

if in first case have view (based on above)

...bla <div id="my-container"> <%= html.partial("mypartialcontrol",mydictionary["kindofpanel"] %> </div>

then create action looks in controller:

public actionresult mypartialcontrol() { homecoming partialview("mypartialcontrol", thedata); }

then add together next jquery function , trigger when want:

$('.my-trigger').click(function(){ $.get('@url.action("mypartialcontrol")', function(data) { $('#my-container').html(data); }); });

written without compiler haven't tested this, should work, fill in blanks , have play around, general idea.

c# asp.net-mvc asp.net-mvc-3 asp.net-mvc-partialview

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -