开发者

Creating and dynamically using content templates and controls

开发者 https://www.devze.com 2023-03-01 00:13 出处:网络
I need to create dynamic template for my site content, and dynamically load .ascx controls in it in Asp.Net c#.

I need to create dynamic template for my site content, and dynamically load .ascx controls in it in Asp.Net c#.

For example I have b开发者_JAVA技巧lank default page, and in it dynamically load my html template which is stored in database or just in html page, and then in that html (let's say div's) to dynamically load other .ascx controls.

I need this to load different site template for different user or domain, and with different widgets.

This kind of idea is used in Joomla, you can change your html template and css, and have different look for different subdomain.

Any ideas will be excellent.


In general, you'd use the .NETs masterpages to create the template with placehholders for data, and from that masterpage (or your pages that uses it), dynamically control which parts of the placeholders that should show what, which controls to be loaded and so on.

Have a good look at masterpages http://msdn.microsoft.com/en-us/library/wtxbf3hh.aspx

//Loading an .ascx dynamically is as simple as:
MyControlType myControl = (MyControlType)LoadControl("/location/MyControlType.ascx");
// and simply add it to the placeholders controls by
myPlaceHolder.Controls.Add(myControl);

The logic of what load and add is of course up to you.

0

精彩评论

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

关注公众号