views:

62

answers:

2

I am working on a code base which as VBScript code embedded in HTML. I've noticed the following two different tags around said lines of code

<%= MyFunc(val1) %>

and

<% MyFunc(val1) %>

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

+12  A: 

<% evaluates an expression in server code but doesn't emit output.

<%= also evaluates the expression but wraps the result in Response.Write, so it produces output.

LBushkin
Genius. That makes sense with what I'm seeing. Thanks!
Rob Segal
+4  A: 

When you see:

<%= MyFunc() %>

it really means:

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

Its short hand for writting output to the response.

<%
MyFunc()
%>

The above will just run the code but won't write it to the response unless it has some Response.Write's inside the Function/Sub itself.

Pete Duncanson