I'm very new to Umbraco, C# and MVC and need a little bit help.
I have a Partial View in my master.cshtml returning some database content. Everything works, but i want to speed it up. So I thought, I have to load by jquery/ajax after loading all the other stuff. This works for "normal" views (for those with an real URL).
Can anyone tell me how to load a Partial View "Async"? I don't need code, just the right direction :)
thanks for you reply. Nevertheless the page must be loaded once for the first time. Caching seems to be a good idea for views that must be loaded recurrently.
I want to load my Masterpage, with all the content, but in the little box, where the partial view is building, I want to show the user a simple tag with a text content "is loading..." and change this content after the page is ready loaded.
make a <div id="visitData" onload="javascript:GetVisits()"> Content is loading </div>and close it where you want to add partial view and call controller method
<script type="text/javascript">
function GetVisits(e) {
var ip = $(e).parents("tr").children("td").eq(1).text();
var visitDate = $(e).parents("tr").children("td").eq(0).text();
$.get("/umbraco/surface/SiteVisitors/getVisits", {
id: ip,
visitDate: visitDate
}, function (data) {
$('#visitData').empty();
$('#visitData').html(data);
});
}
and in controller write something like
public class SiteVisitorsController : SurfaceController
{
// GET: SiteVisitors
[HttpGet]
public ActionResult getVisits(string id, string visitDate)
{
var model = Visitor.GetSiteVisitorPageByIPAddress(id, visitDate);
return PartialView("Partials/_SiteVisitors", model);
}
}
Load Partial View by AJAX
Hi @All,
I'm very new to Umbraco, C# and MVC and need a little bit help.
I have a Partial View in my master.cshtml returning some database content. Everything works, but i want to speed it up. So I thought, I have to load by jquery/ajax after loading all the other stuff. This works for "normal" views (for those with an real URL).
Can anyone tell me how to load a Partial View "Async"? I don't need code, just the right direction :)
Thanks! Frank
Hi Frank,
The easiest way to fix performance is to use CachedPartial helper. It's really easy to use and great performance results.
Look here - https://our.umbraco.org/documentation/reference/templating/mvc/partial-views
Ajax is good - but it's perfect I think. The best way is to fix serverside.
Cheers,
Alex
Hi Alex,
thanks for you reply. Nevertheless the page must be loaded once for the first time. Caching seems to be a good idea for views that must be loaded recurrently.
I want to load my Masterpage, with all the content, but in the little box, where the partial view is building, I want to show the user a simple tag with a text content "is loading..." and change this content after the page is ready loaded.
Hi,
make a
<div id="visitData" onload="javascript:GetVisits()"> Content is loading </div>
and close it where you want to add partial view and call controller methodand in controller write something like
Hi,
this is the solution! Thanks a lot! My Code was very similar but I didn't know the correct URL:
This was the magic row .... I forgot umbraco/surface
Greetings Frank
Great Frank, I'm glad that you solved the problem.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.