I have this ASP code <% sub mysub mytestvariable = 111 end sub call mysub response.write mytestvariable %> Code (markup): Why does the above code show BLANK value when I response.write mytestvariable ? Shouldn't it output 111? Whats the solution?
try this complete your works in sub not off sub <% sub mysub mytestvariable = 111 response.write mytestvariable end sub mysub %>
It's because the variable mytestvariable is in a local code block and only has scope in that code block. You need to declare it outside of the block. The correct way to do it would be to use a function with a return value: function myfunction() mytestvariable = 111 return mytestvariable end function Response.Write(myfunction())