What is the difference between "<%" and "<% =" in embedded VBScript?

I am working on a codebase that, like VBScript code, is embedded in HTML. I noticed the following two different tags around the specified lines of code

<%= MyFunc(val1) %>

and

<% MyFunc(val1) %>

What is the difference in using the "=" symbol at the beginning of these sections?

+3
source share
2 answers

<% evaluates the expression in the server code, but does not display the result.

<%= also evaluates the expression, but completes the result in Response.Write, so it outputs the result.

+15
source

When you see:

<%= MyFunc() %>

it really means:

<%
Response.Write( MyFunc() )
%>

His short hand is for outputting the answer.

<%
MyFunc()
%>

, , Response.Write /Sub.

+5

Source: https://habr.com/ru/post/1725964/


All Articles