Upload view by parameter

1

How do I call a view passing a parameter?

Type, if parametro = 1 <h1>Teste1</h1> else <h1>Teste2</h1>

    
asked by anonymous 08.10.2015 / 21:01

1 answer

1

By answering the question: How to send 2 Controller objects to the View in C # ASP.NET MVC? , do the following

In your controller :

public ActionResult View()
{
    ViewBag.Parametro = 1;
    return View();
}

And in your View:

@if (((int)ViewBag.Parametro) == 1) {
    <h1>Teste1</h1>
} else {
    <h1>Teste2</h1>
}
    
08.10.2015 / 21:14