Change DIV style according to FORM

Asked

Viewed 286 times

2

I have the following application to login

public ActionResult Logar(String Login, String Senha)
{
    var bdUsuario = ClientesAplicacaoConstrutor.ClientesAplicacaoEF();
    var usuario = bdUsuario.ListarTodos().Where(x => x.Codigo == Login && x.Senha == Senha);

    if (usuario.Count() == 1)
    {
        var user = usuario.First();
        FormsAuthentication.SetAuthCookie(user.ID.ToString(), false);
    }
    return RedirectToAction("Index");
}

The entire form is inside a div ID formLogin.

I would like to add the login condition a way to change the display of the div id formLogin and consecutively display another content after the user logs in.

Since Controller can’t find the div element ID, I tried with Panel and Literal tagged runat="server" but I still couldn’t locate my div to change the properties CSS.

1 answer

2


In his View you’ll have to use a if thus:

@if (Request.IsAuthenticated && User.Identity.IsAuthenticated)
{
    //logado                  
}
else
{
    //não logado                   
}

Obs: Remembering that now has no tags runat="server" as it concerns MVC and not Webforms.

Browser other questions tagged

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