Preloader Asp.net MVC

Asked

Viewed 161 times

3

How can I do a preloader(carrying...) while it is rendering the view on @RenderBody ?

In search only found examples using Partial, but Views not

Any idea?

1 answer

1


It’s not much of a secret:

Controller

public JsonResult MinhaAction(int id)
{
    // Preenchimento de 'meuJson', e tal
    return Json(meuJson);
}

View

I’m using jQuery, and supposing you’ve already found a "loading" screen somewhere. I’m going to assume that it sits inside a <div> whose id is "loading":

$('#meuLink').click(function()
{
    var action = '@Html.ResolveUrl("~/MeuController/MinhaAction/")' + $('#campoId').val();
    $('#carregando').show()
    $.getJSON(action, null, function(variavelDeCallback) 
    {
        // Faça aqui o que precisa com 'meuJson'
        $('#carregando').hide()
    });
});
  • There is a return Json gypsy, I wanted the whole page Return View()

  • @Rod This is behavior done by Javascript. It depends on how your View is called. If it’s by Ajax, my answer will do. Otherwise, I don’t know if you can do it.

  • is called with same actionlink

  • @Rod as the Gypsy spoke since the link is loaded by ajax has no problem being View or Partialview, of course being View, by default Layoutmaster will come along and you can give replace of everything (which I do not think good idea) or else in the view remove Layoutmaster!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.