7
I’m coding a page in Visual Studio, in ASP.Net MVC and I need to display one div
only when there is a POST
on this page.
This is a form that will make the POST
on the page itself. When POST
, I will display a send confirmation message.
What I have is more or less like this:
@using (Html.BeginForm())
{
<fieldset>
<legend class="hidden">Contato</legend>
<div class="msg-success">
<p>Sua mensagem foi enviada com sucesso.</p>
</div>
@Html.LabelFor(m => m.Name, "Nome*")
@Html.TextBoxFor(m => m.Name, new { id = "Name" })
@Html.LabelFor(m => m.Email, "E-mail*")
@Html.TextBoxFor(m => m.Email, new { id = "Email" })
<input type="submit" id="Send" name="Send" value="Enviar" />
</fieldset>
}
I would like an equivalence to if($_POST)
to display the div
:
<div class="msg-success">
<h3>Obrigado!</h3>
<p>Sua mensagem foi enviada com sucesso.</p>
<p>Aguarde, que logo entraremos em contato.</p>
<span class="close">X</span>
</div>
Complementing the complement, the Request.Inputstream, is useful for example when you want to handle the request manually, such as receiving file upload, where you receive and read all bytes of Request. And the Acceptverbs, is a very flexible way of restricting and accepting multiple arguments in the same method.
– Fernando Leal