Jun 10, 2010, 1:40 PM
[CLOSED] Set Template in Code Behind
Hi, I'm running across a problem trying to create an XTemplate for a DataView from code behind.
When I'm doing it in source view it looks like this:
<Template runat="server">
<Html>
<ul class="">
<tpl for=".">
<li>{message}</li>
</tpl>
</ul>
</Html>
</Template>
This works without problem. The JS generated looks like this
But I require to create the template from Code Behind as I'm making a Custom Server Control, so I tried it like this:
But this doesn't work. The LI gets generated alright, but the value to be subsistuted by "{message}"
The generated HTML when setting template from code behind
As you will note it's an array with a single element instead of multiple like the other. The data is fine. So I'm stumped on what to do next.
When I'm doing it in source view it looks like this:
<Template runat="server">
<Html>
<ul class="">
<tpl for=".">
<li>{message}</li>
</tpl>
</ul>
</Html>
</Template>
This works without problem. The JS generated looks like this
html: ["<ul class=\"\">","<tpl for=\".\">","<li>{message}</li>","</tpl>","</ul>",""]
But I require to create the template from Code Behind as I'm making a Custom Server Control, so I tried it like this:
DataView.Template.Html = "<ul class=''><tpl for='.'><li>{message}</li></tpl></ul>"
But this doesn't work. The LI gets generated alright, but the value to be subsistuted by "{message}"
The generated HTML when setting template from code behind
html: ["<ul class=''><tpl for='.'><li>{message}</li></tpl></ul>"]
As you will note it's an array with a single element instead of multiple like the other. The data is fine. So I'm stumped on what to do next.