N
news
I'm trying to encapsulate a bunch of html widgets such that a
containing page can call them to draw themselves in whatever order it
chooses as well as easily add new ones.
In order to do this each widget registers itself by returning an id
code and a reference to the subroutine that generates its HTML content.
This works fine using vbScript's GetRef, but I've just noticed that if
the subroutine you get a reference to contains any Response.Write
statements, they get executed immediately as you take the reference and
not when the function is called. For example:
<%
dim functionReference
function renderWidget
response.write "bar"
renderWidget = "foo"
end function
functionReference = getRef("renderWidget")
response.write "---"
response.write functionReference
%>
You'd expect this to generate "---barfoo", but no, you get "bar---foo".
Clearly I'm hitting a response.write optimisation too far here and it's
easy to avoid, but thought people would be interested here
containing page can call them to draw themselves in whatever order it
chooses as well as easily add new ones.
In order to do this each widget registers itself by returning an id
code and a reference to the subroutine that generates its HTML content.
This works fine using vbScript's GetRef, but I've just noticed that if
the subroutine you get a reference to contains any Response.Write
statements, they get executed immediately as you take the reference and
not when the function is called. For example:
<%
dim functionReference
function renderWidget
response.write "bar"
renderWidget = "foo"
end function
functionReference = getRef("renderWidget")
response.write "---"
response.write functionReference
%>
You'd expect this to generate "---barfoo", but no, you get "bar---foo".
Clearly I'm hitting a response.write optimisation too far here and it's
easy to avoid, but thought people would be interested here