As expected?

E

Evertjan.

I did not expect this to work as expected:

<%
function a()
%>ha !<br><%
end function

a
a
a
a
a
%>

So, why do we use so much response.writes?
 
P

Patrice

Mixing HTML and VBScript code is generally considered as less easier to
read. For example if you want to use a variable instead of ! you'll have
something like :

Sub a(ByVal Mark)
%><!--ha--><%=Mark%><br><%
End Sub

Opposed to :

Sub a(ByVal Mark)
Response.Write("ha ")
Response.Write(Mark)
Response.Write("<br>")
End Sub



Patrice
 
A

Aaron Bertrand [MVP]

I agree with Patrice, it's easier to read.

In some projects I have used a shortcut function like this:

function rw(s)
response.write s
end function

rw "Hello"
rw "Goodbye"

I have also used wl, which mimicked writeline (adding carriage returns /
<br> etc. so I didn't have to think about putting the HTML into the text).

I think another factor is that many people are in the habit of avoiding
context switching because IIS *used* to be a bit inefficient with it.
 
M

Michael D. Kersey

Evertjan. said:
I did not expect this to work as expected:

<%
function a()
%>ha !<br><%
end function

a
a
a
a
a
%>

So, why do we use so much response.writes?
Some Microsoft URLs term the above a "render function", e.g.,:
"Migrating to ASP.NET: Key Considerations" by Jim Kieley:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspnetmigrissues.asp

According to that Microsoft article and others, "render functions" are
not allowed in ASP.NET, which is unfortunate. Personally I think they're
kinda cute and handy, yet another reason to use ASP instead of ASP.NET.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top