0

从aspx页面迁移到ascx控件时,我将大量的头文件包含到代码隐藏文件中,我一直将它们包装在RegisterClientScriptBlocks中,并使用linq保持大型多行整齐。RegisterClientScriptBlock CDATA内联声明

但是已经注意到内联声明<%serverside.code%>现在没有得到执行。

ClientScript.RegisterClientScriptBlock(GetType(Page), "test", <a><![CDATA[ 
     <script type="text/javascript"> 
      testValue = '<%=Page.Title%>'; 
     </script>]]></a>, True) 

产生;

<script type="text/javascript"> 
    testValue = '<%=Page.Title%>'; 
</script> 

回答

0

为了解决这个问题,我结束了.value的CDATA块和附加的代码变量,然后开始一个新的CDATA块与多语句

ClientScript.RegisterClientScriptBlock(GetType(Page), "test", <![CDATA[ 
    <script type="text/javascript"> 
     testValue = ']]>.Value + Page.Title + <![CDATA['; 
     //more code 
    </script> 
    ]]>.Value, True) 
其余