Parsing controls

  • Thread starter Thread starter Stirling
  • Start date Start date
S

Stirling

Hi all
currenly I am trying to load a static file from a the file system in
asp.net and parse it to produce ASP.net controls from the file. In a
quick prototype I have use the Page.ParseControl() method to create the
control and then add it to the page. However I would like to move this
functionallity out to a HttpHandler to decouple this functionally from
the rest of the site.

However, I can't seem to find a way to do this, as the parseControl
method is protected on the page class. Is there somewhere else in the
framework withe this functionallity? I want to build this functionallty
up front, using the Front Controller pattern as the pages themselves do
not need to know anything about the parsed controls. (Sorry I mightn't
be very clear in my explanation.)

Anybody have any ideas?

Thanks in advance

S.
 
My problem is that the static file is produced within a CMS and I have
no control over (the files are outside the boundry of the app). The
content contains ASP server side includes, which need to be parsed
before they are sent to the response. If I am working on a page, I can
do this easily by using the ParseControl() method, however as I said
before I would like to move it out of the Page.
 
Stirling said:
Hi all
currenly I am trying to load a static file from a the file system in
asp.net and parse it to produce ASP.net controls from the file. In a
quick prototype I have use the Page.ParseControl() method to create the
control and then add it to the page. However I would like to move this
functionallity out to a HttpHandler to decouple this functionally from the
rest of the site.

However, I can't seem to find a way to do this, as the parseControl method
is protected on the page class. Is there somewhere else in the framework
withe this functionallity? I want to build this functionallty up front,
using the Front Controller pattern as the pages themselves do not need to
know anything about the parsed controls. (Sorry I mightn't be very clear
in my explanation.)

Have you tried using UserControls (.ascx) files? This is what they're made
for. See Page.LoadUserControl.

John Saunders
 
Stirling said:
My problem is that the static file is produced within a CMS and I have no
control over (the files are outside the boundry of the app). The content
contains ASP server side includes, which need to be parsed before they are
sent to the response. If I am working on a page, I can do this easily by
using the ParseControl() method, however as I said before I would like to
move it out of the Page.

"Move it out of the Page": what exactly do you mean by this? For instance,
did you realize that Page implements IHttpHandler? You can simply declare
your handler as a subclass of Page, without an ASPX file. You then have all
of the facilities of Page to use.

As to server-side includes, those are parsed by IIS normally. Are you
planning to parse them yourself?

John Saunders
 
Sterling,

Create your own cusomer server control, override the Render method and build
the html output you require in that. You could even then place this in a
user control and set it's output cache property so the file was read only
intermittently greatly improving performce.

About 15-20 lines of code.

Ben Walker
 

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

Similar Threads


Back
Top