In my database I am storing html that also includes asp inline expressions <%= %>
. I need to have these inline expressions rendered on page, but they are being rendered as string literals.
For example. My database field 'Description' stores HTML markup and content. Within the data in this field there are also asp .net inline expressions such as <%= AuthorName %>
. These variables are declared in the code behind and need to be rendered on page wherever the 'description' is bound to.
Also, there are some user controls (.ascx
) controls that need to be dynamically rendered.
Here's some detailed example. My code behind has certain variables declared:
protected Int64 EventId, EventInstanceId;
protected string EventName, HostedBy, Tag, ShortDescription, LongDescription;
protected decimal Cost, EarlyRegDiscount;
protected DateTime StartDateTime, EndDateTime, EarlyRegDate;
These variables are initialized on Page_Load
through information stored in the database.
My front end looks something like this:
<div id="EventName">
<%= EventName %>
</div>
<div id="Description">
<%= LongDescription %>
</div>
The c# string variable (and associated database field) LongDescription
contains additional HTML
markup, as well as asp inline expressions such as <%= HostedBy %>
. So wherever <%= LongDescription %>
is rendered and it's containing HTML
markup, it should also render any embeded expressions such as <%= HostedBy %>
.
How can this be achieved?