PDA

View Full Version : [CLOSED] Example Populating Panel's Content (HTML required for SEO)



michaeld
May 03, 2013, 8:46 AM
At the presentation layer, it is easy to do the following:



<ext:Panel ID="P" runat="server">
<Content>
<h1>Hello World!</h1>
</Content>
</ext:Panel>


The following will render something to the effect of:



<div id="P_Content" class="x-hidden"> <h1>Hello World!</h1></div>

... which is good because this is a pure HTML stream that a webcrawler can see.

But dynamically who do I do the equivalent?

P.html produces javascript with html as a property. That's not acceptable html stream.



P.Controls.Add(
new HtmlGenericControl("h1") { InnerHtml = "Hello World!" }
);

... produces the Html stream but not displayed by Ext.Net.

So how do you write the text to P.Content?

Daniil
May 03, 2013, 9:17 AM
Hi @michaeld,

Please use ContentControls instead of Controls.

michaeld
May 03, 2013, 10:13 AM
Thank you. I had actually forgotten that subtlety. Shame there's no way to cause Controls.Add to exception, as using it will break resize and flex.

michaeld
May 03, 2013, 10:15 AM
Still... I would like to know how to populate ITemplate dynamically. Like, how can I dynamically fill htmlbin?

Daniil
May 03, 2013, 11:59 AM
A markup HtmlBin property puts the things into a Control's Controls collection.

So, in code behind, please just populate a Controls collection.