I'm moving significant amounts of header includes into codebehind when migrating from aspx pages into ascx controls, I've been wrapping them in RegisterClientScriptBlocks and using linq to keep the large multiline tidy.
However have noticed that the inline declarations <%serverside.code%>
are now not getting executed.
ClientScript.RegisterClientScriptBlock(GetType(Page), "test", <a><![CDATA[
<script type="text/javascript">
testValue = '<%=Page.Title%>';
</script>]]></a>, True)
Produces;
<script type="text/javascript">
testValue = '<%=Page.Title%>';
</script>
To solve this I ended the cdata block with a .Value and appended the code variable, then started a new cdata block with the rest of the multiline statement
ClientScript.RegisterClientScriptBlock(GetType(Page), "test", <![CDATA[
<script type="text/javascript">
testValue = ']]>.Value + Page.Title + <![CDATA[';
//more code
</script>
]]>.Value, True)