开发者

Set CMS content in .NET

What would be the best approach to set dynamic content from the database to controls in an aspx page?

My database consists of pages (index.aspx, home.aspx and so on) which consists of controls (DivStart, LabelDescription, and so forth).

The first technique that came to my mind was looping through all the controls in the page, looking for controls that have a certain class, e.g. "Cms_DivStart", and would then set the inner html for that control from the database control called "DivStart". The proble开发者_运维百科m is only runat server controls shows up, and I don't want to make all controls server side.

I could store all the dynamic texts for a page in hidden variables and set it with jQuery when the page has loaded, but that would make the text not show up directly..

Any other ideas would be greatly appreciated.

Thanks /Andreas


You could use asp:PlaceHolder tags, these don't add any html unless they are utilised.


You can write a custom class, I'll call it "CustomPage", that inherits the System.Web.UI.Page class. Then your pages can inherit "CustomPage". In this class, add methods to retrieve data, set custom properties and display your content in the available controls.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜