It works, I just add:
<span runat="server"> <js code..> </span>
and changed helper to (without single quotes):
<%= CMS.GlobalHelper.ResHelper.GetString("ReceiptsList.ProductName") %>
質問
I am rendering page layout inside javascript but I would like to use there some CMS helpers. Rendering works well but helpers doesn't work (I obtained "NaN" instead of text I wanted). How can I add helpers to javascript variable?
var detailsTemplate =
'<table cellspacing="0" cellpadding="0">' +
'<tr>' +
'<th class="info">' +
<%# CMS.GlobalHelper.ResHelper.GetString("ReceiptsList.ProductName") %> +
'</th>' +
'</tr>' +
'<tbody>' +
'{0}' +
'</tbody>' +
'</table>'
解決 2
It works, I just add:
<span runat="server"> <js code..> </span>
and changed helper to (without single quotes):
<%= CMS.GlobalHelper.ResHelper.GetString("ReceiptsList.ProductName") %>
他のヒント
Set single quotation marks around the ASP tags:
'<th class="info">' +
'<%# CMS.GlobalHelper.ResHelper.GetString("ReceiptsList.ProductName") %>' +
'</th>'
Look at the code generated and you will see, without the quotes you will have something like '<th>' + foo + '</th>'
which will cause your current error. With the quotation marks you will have '<th>' + 'foo' + '</th>'
which will run fine.