Doubt as to Request.Form

0

What is the Request.Form? How do I interpret these lines?

if (Request.Form["chkTornarObrigatorio"] != null)
                                    ventRegPendencia.IcDocObrigatorio = int.Parse(Request.Form["chkTornarObrigatorio"]);
    
asked by anonymous 13.11.2014 / 14:21

2 answers

2

Request.Form is used to get information from a submit of an HTML form that was sent via POST. Because the POST information is invisible to the user, you must retrieve it through the Request method.

The line in question is interpreted as follows:

//O campo chkTornarObrigatorio foi enviado pelo formulário de uma outra página via post, nesta linha verificamos se ele está preenchido
if (Request.Form["chkTornarObrigatorio"] != null)
{
    //Se o campo existir, nós pegamos o valor do campo e convertemos para inteiro a
    ventRegPendencia.IcDocObrigatorio = int.Parse(Request.Form["chkTornarObrigatorio"]);
}

Basically, you're looking for the value that was sent from another page, see this link as a reference.     

13.11.2014 / 14:29
2

Request is an ASP.NET class that allows you to read values sent during a Web request.

  

What is Request.Form?

It is a property ( Request.Form ) of the Request class that you can use to retrieve the values of form elements posted in the body of the HTTP request.

  

How do I interpret these lines?

//Com base no nome do elemento do seu formulário,
//verifica se o campo chkTornarObrigatorio não está nulo
if (Request.Form["chkTornarObrigatorio"] != null)
{
    //Caso não esteja nulo, converte o valor do campo chkTornarObrigatorio 
    //para o tipo inteiro e associa a ventRegPendencia.IcDocObrigatorio
    ventRegPendencia.IcDocObrigatorio = int.Parse(Request.Form["chkTornarObrigatorio"]);
}

Take a look at the links I've added for more details.

    
13.11.2014 / 14:25