Condition for verifying null variables does not work

4

I'm developing an ASP (Classic) page and on this page I have this:

<%if(textocontrato) = "NULL" Then%>
<td >Texto Contrato</td>
<td ><input type="text" name="textocontrato" value="<%=textocontrato%>" size=30 maxlength=30></td>
<%Else %>
<td >Texto Contrato</td>
<td ><input type="text" name="textocontrato" value="<%=Server.HTMLEncode(textocontrato)%>" size=30 maxlength=30></td>
<%End If%>

What I want is that if textocontrato is = NULL executes the HTML from above if not NULL executes the bottom, however even when textocontrato it is null it runs underneath and ends up giving me error, because the HTMLEncode is not receiving anything. What am I doing wrong?

    
asked by anonymous 19.06.2017 / 13:20

1 answer

10

You can try this in 3 ways.

1st Way:

<%If IsNull(textocontrato) Then%>

2nd Way:

<%If (textocontrato) == null Then%> //Note que null não tem aspas

3rd Way:

<%If (textocontrato) == "" Then%>
    
19.06.2017 / 14:52