By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,652 Members | 1,473 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,652 IT Pros & Developers. It's quick & easy.

Building a control that loads its template from a database

P: n/a
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

Jan 29 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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.
On 29 Jan, 16:20, "DC" <d...@upsize.dewrote:
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
Jan 29 '07 #2

P: n/a
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
On Jan 29, 6:15 pm, "sticky" <tchap...@sis.tvwrote:
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.

On 29 Jan, 16:20, "DC" <d...@upsize.dewrote:
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- Hide quoted text -

- Show quoted text -

Feb 1 '07 #3

P: n/a

DC wrote:
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/de...ebcontrols.asp

Feb 1 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.