(vbscript) GetRef and Response.Write
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:
renderWidget = "foo"
functionReference = getRef("renderWidget")
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 :)
Re: (vbscript) GetRef and Response.Write
> dim functionReference
> function renderWidget
> response.write "bar"
> renderWidget = "foo"
> end function
> functionReference = getRef("renderWidget")
> response.write "---"
> response.write functionReference
Doing some more digging, it's not the response.write that is the
problem, it's the assignment of the result of GetRef.
If you do functionReference = GetRef("foo") then foo is executed there
and then and the result stored in the functionReference
if you do set functionReference = GetRef("foo") then it works as you'd
|All times are GMT. The time now is 10:35 AM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.