Aspx's Html Injection

  • Thread starter Thread starter orianavim
  • Start date Start date
O

orianavim

Hi,

I'm try to find an easy efficient way to generate my web pages
dynamically from an xml/text file.

What exactly I want?

I want that whenever a pages is loaded it will go and read an xml/text
file which will include the style of the page (tables,div, web
controls, etc) and will build the page according to that. Meaning that
initially the page ("default.aspx") has no html on it and its
entire html is built on the fly, per request. Please keep in mind that
that text/xml file may include names of webcontrols that will have to
be added to the page as will and will render themselves.

In a nutshell, I'm trying to find a way to inject to an aspx file its
"hard core" html (the html which exist at design time in the aspx
file) before its start to load and render itself. Please keep in mind
that I cannot/don't want to start creating those files on the fly,
hence, no file IO writing.

I there any simple way to implement such a thing?

Any idea would be great,

thanks,
 
Hi,
I'm try to find an easy efficient way to generate my web pages
dynamically from an xml/text file.

What exactly I want?

I want that whenever a pages is loaded it will go and read an xml/text
file which will include the style of the page (tables,div, web
controls, etc) and will build the page according to that. Meaning that
initially the page ("default.aspx") has no html on it and its
entire html is built on the fly, per request. Please keep in mind that
that text/xml file may include names of webcontrols that will have to
be added to the page as will and will render themselves.

In a nutshell, I'm trying to find a way to inject to an aspx file its
"hard core" html (the html which exist at design time in the aspx
file) before its start to load and render itself. Please keep in mind
that I cannot/don't want to start creating those files on the fly,
hence, no file IO writing.

I there any simple way to implement such a thing?

Any idea would be great,

thanks,

You can have a "PlaceHolder" in you page. You can add all sorts of
controls (including html) to that.

Also look up on the ParseControl method which can turn an "html string"
into a set of controls (you can turn the text of an ascx file into
"live controls").


Hans Kesting
 
I don't believe there is. The problem here is that it seems that you
don't want to inject HTML, but rather, the ASPX page itself. What I mean by
this is that an ASPX page has HTML in it, but it has tags in it that are
interpreted by the ASP.NET runtime and rendered appropriately.

AFAIK, you can't inject the tag for say, a textbox that is interpreted
on the server and then have ASP.NET interpret it.

Your default.aspx page is going to be rendered based on some condition,
right? Why not just evaluate that condition, and then branch off the HTML
in the page accordingly?

Also, you could put almost all of the logic in the ASPX page itself, and
then change it when you need to. That way, all you have to do is make the
change to the page, and ASP.NET will handle the compilation.

Finally, you will probably get a perf boost doing it this way as well,
since the pages are compiled code (better than reading from the file and
then writing to the stream).

Hope this helps.
 
It should be no problem to override the page's render method and build
your page there, but it does seem like you are going to be doing a lot
of programming yourself for no reason. If you are actually going to
read the whole page definition in the xml file then you are in fact
reading the page.

protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
//your code goes here.
}
 
I really agree with the other comments; however a common technique that seems
close to what you describe is to use an Xml Control at the top of the "page",
and supply it dynamically with the xml document and xsl stylesheet document
for the TransformSource. The control will automatically perform the
XslTransform, the result being a complete custom page.
Peter
 

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