templatable user controls.

G

George Ter-Saakov

I am trying to create templatable user control.
So idea is to have code in .cs files and HTML (with server control declarations) in the .ascx files.

Control has one .cs file since functionality does not depend on selected template.
Control should/might have multiple templates (ascx files).

Problem: template is selected in run time.
How is it done?

One of the examples is "Community Server". Page simply consist of directives to include UserControls (besides of HTML) like

<%@ Register TagPrefix="Galleries" Namespace="CommunityServer.Galleries.Controls" Assembly="CommunityServer.Galleries" %>

<Galleries:AggregatePortalPictureListing EnableTitle="false" Count="5" ...../>

And then in themes folder there are files "Skin-AggregatePortalPictureListing.ascx" one for each different theme.

So as you can see there is one compiled class CommunityServer.Galleries.Controls.AggregatePortalPictureListing which in runtime based on selected theme loads "Skin-AggregatePortalPictureListing.ascx" from appropriate folder and hooks up all event handlers and controls to member variables....



Thanks
George.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top