Inline Expression Resolution

D

Darin Higgins

Hi everyone:

I have a particular situation where I'd like to serve up the content of
essentially static html coming out of a database for a website.

I've created a generic user control to actually handle retrieving the
html text and I've overridden the RENDER method to render the html at
the point the control is rendered (the static text actually sits inside
a master template page and the static control is dynamically created on
the master page)

All this works fine as it is.

However, I'd like to be able to use small inline expressions (of the
form
<%= FunctionName() %> at various places in the otherwise static html and
have those expressions evaluated when the page is rendered, just like a
normal ASPX or ASCX page. But that doesn't seem to work, when you write
the text as output through the HTMLTextWriter you get through the RENDER
method

I assume I'm not inserting the html early enough in the rendering
pipeline.

Would anyone have any ideas how to go about doing this (or maybe there's
a better way to accomplish the same thing that I'm not familiar with?

Thanks
Darin
 
B

Bruce Barker

in aspx, the inline expression are evaluated when the page is compiled the
first time.

for example

<html>
<body>
<% printHello(); %>
</body>
</html>

get compiled to (pseudo code)

_renderPage(HtmlTextWriter __output)
{
__output.Write("<html>\r\nbody\r\n");
printHello();
__output.Write("\r\n</body>\r\n</html>\r\n");
}

the compiled code is loaded into memory, then called.

a coomon way to do what you want is to use webclient to callback into you
website to render the static page. you can also use the asp.net runtime to
compile your page, and get an object handle.

-- bruce (sqlwork.com)
 
T

Tom.PesterDELETETHISSS

Interesting question. I dont have a sample but maybe this will get you in
the right direction :

"
Capturing content from another Page in the Current Application

If you need to capture content from another page altogether you can take
advantage of a very powerful function in the Server object: Server.Execute().
Server.Execute() let's you run another ASP.Net page, pass in a TextWriter
object and then return control back to the current page, which can then retrieve
the TextWriter and its content easily.
"

Its from http://west-wind.com/weblog/posts/481.aspx

Using that approuch you could present asp.net the database content as a page.
Maybe you first have to dump the content to a physical file but I think its
also possible to skip this intermediate stage but haven't tried something
like this.

Hope this hepls a bit.. Let me know how it goes.

Cheers,
Tom Pester
 

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,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top