It works as it is now, the only thing you have to do is to wrap the string you get from GetUserCodeRegion with <!-- and -->, preferably by placing the comment tags on separate lines. You should specify as comment to GetUserCodeRegion either // or '
When the parser is scanning the file, it will find the regions and will give them one by one to you as is to you when you call GetUserCodeRegion, though without the comments. As the surrounding text is re-generated, the previous comments are removed, and the new ones are inserted.
You could also do:
<!--
<%= DotNetTemplateEngine.GetUserCodeRegion("Foo", "//");
-->
which should do the trick IMHO. Did you try this and it didn't work?