I have encountered an issue while creating a new literal control from code behind. I am able to add standard HTML into it successfully, however, when I try to insert <%= SomeDiv.ClientID %>
into the literal control, it simply prints exactly what is in the code behind.
Code behind:
new LiteralControl("<div id='" + paneID.Replace(" ", "") + "_Expand' runat='server' onclick='ChangePanelHeader('<%= " + paneID.Replace(" ", "") + "_Expand.ClientID %>'" + ", " + "'<%= " + paneID.Replace(" ", "") + "_cpe.ClientID %>')' class='rhsCollapsiblePanelsHeader'>" + paneTitle + "<br /><br /></div>" + paneContent)
Upon page load, in Browser Source:
<div id='Tellafriend_Expand' runat='server' onclick='ChangePanelHeader('<%= Tellafriend_Expand.ClientID %>', '<%= Tellafriend_cpe.ClientID %>')' class='rhsCollapsiblePanelsHeader'>Tell a friend<br /><br /></div>
Desired output:
<div id='Tellafriend_Expand' runat='server' onclick='ChangePanelHeader("MyTelAFriendID_Expand", "MyTelAFriendID_cpe") class='rhsCollapsiblePanelsHeader'>Tell a friend<br /><br /></div>
Error message in Firefox:
syntax error
[Break On This Error]
ChangePanelHeader(<%= Tellafriend_Expand.ClientID %>, <%= Tellafriend_cpe.Cli...
default.aspx (line 1, col 20)