Building a control that loads its template from a database

D

DC

Hi,

I have the requirement to build a control that will read its template
from a database. (I call all the stuff one would normally place
between the start and end tag of a placeholder in a usercontrol
"template" here.) The purpose is to provide HTML snippets with the
ability tho change the .ascx part without manipulating and deploying
files.

I see the TemplateControl class and its "LoadTemplate" control but
that seems to load from a physical path only (I am restricted to
framework 1.1). Does someone know an approach or a code sample for
what I want to do?

TIA for any hint,
Regards
DC
 
S

sticky

that could be complicated

if you just want to display static html, with no .net controls, then
try overriding the render method for the control and outputting the
stored template then.

if you want to have controls in your usercontrol, and do things like
saving their viewstate then things will become a lot more complicated.

you could try serializing the controls to the database and then
deserializing them and loading them (you have to do this on page_init
for them to be automatically added to the viewstate)

you can also dynamically create user controls, which could be the
easiest way i think


its difficult to know what is the best option with out more
information on what you are trying to do.
 
D

DC

Thanks sticky,

I did not find a proper way to load templates without using file
access. I therefore changed the requirements and will load the ascx
from a file now (LoadControl). My main intent is that the ascx code is
kept in a database, so I will implement a mechanism to sync the data
with a .ascx file.

Regards
DC
 
M

marss

DC said:
Hi,

I have the requirement to build a control that will read its template
from a database. (I call all the stuff one would normally place
between the start and end tag of a placeholder in a usercontrol
"template" here.) The purpose is to provide HTML snippets with the
ability tho change the .ascx part without manipulating and deploying
files.

Why not to use a web custom control? Is is more suitable for dinamic
content loading.
http://msdn.microsoft.com/library/d...l/vbconwebusercontrolsvscustomwebcontrols.asp
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top