Dynamically rendering ASP.NET code

  • Thread starter Thread starter Nils Magnus Englund
  • Start date Start date
N

Nils Magnus Englund

Hi,

I want to store .aspx code in a database for easier management, editing etc.
(for a CMS-ish application)

Is this feasible without getting into massive amounts of trouble? The
codebehind will be static and on the filesystem, it's only the .aspx content
I want to be able to change (several, if not all, pages can share the same
simple codebehind for most content).

Any tips and suggestions would be greatly appreciated. Perhaps I'm heading
in the wrong direction here, if so, I'd still be thankful for any other tips
which would give me approximately the same functionality.

I though about creating my own XML format, then manually parsing the tags in
the e.g. "cms"-namespace. (which effectively would let the users write any
xml-compliant html code mixed with our own "<cms:"-style tags, which would
be replaced by e.g. server controls) - but I figured this would be too much
work...

Let's say I have the following .aspx code stored in a string variable:

<body>
<asp:Label id="Label1" />
</body>

I would then want to specify (in code) what class that WebForm should derive
from, and thus letting that class set the properties for Label1 (assuming
Label1 is defined in the class).


Thanks,
Nils Magnus Englund
 
Scott Simons said:
I think I understand what you are trying to do, but am not sure. In any
case, if the code behind would be the same the only thing you could really
change in the aspx files would be the layout. Don't waste your time with
this, use stylesheets. If each user needs a different layout think of
ways
to allow each user to create their own stylesheet.

Actually, in addition to the layout, I would be able to change the content
(which would be plain text in the .aspx). I was hoping to let the user add
tags like e.g. <my:SomethingDynamic key="value" /> (which would be replaced
by some nifty dynamic content in the client output).

The "user" in this scenario would be the people able to modify the .aspx
code in the database, but not mess with the codebehind.

The .aspx pages would only be the middle content, as I use some sort of
templating around it - so layout-wise, the changes would only be very
moderate.


Sincerely,
Nils Magnus Englund
 

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

Back
Top