ajax - ASP.NET MVC 3 Partial View dynamically rendered and linked from dynamic list in view -
in mvc 3 application, have view contain partial view. view have list of dynamically generated links. link has cause partial view render detailed information linked item.
would use ajax this? if so, since haven't worked ajax before, there documentation using in mvc 3 app?
also when view first loaded, partial view either not loaded or ideally show separate partial view. thoughts on way of doing this?
thanks help.
create action method returns partialviewresult:
[httpget] public actionresult detailedlinkinfo(int someidentifier) { var detailedlinkinfo = getfromsomewhere(); return partialview(detailedlinkinfo ); } then create partial view, strongly-typed type of detailedlinkinfo (let's it's dynamiclink.
@model webapplication.models.dynamiclink @* bunch of html detailed info *@ then use jquery on client-side. give links class makes easier hook event:
$(function() { $('a.dynamic-link').click(function() { $.get('/somecontroller/detailedlinkinfo', someidentifier: $(this).attr('id'), function(data) { $('#some-div').html(data); }); }); }); end result: click 1 of links, jquery perform ajax controller action, bind result div.
hth
Comments
Post a Comment