Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best way to output template HTML files. 1

Status
Not open for further replies.

iaresean

Programmer
Mar 24, 2003
570
ZA
Hi All;

I believe this is a mere quickie. :)

I am writing a basic newsletter template app. I allow users to select from a number of templates, enter their body text for the template and then preview the finished product.

The template files are stored as .html files within my site root.

I currently have a blank aspx page which I would like to use as the preview page. I would first have to read the contents of the template file and then replace key sections with their custom content and then output the result. What is the best way, given your personal experience, for outputing the html to the page?

Thank you for any and all help.



Sean. [peace]
 
I'd look at the other way round and use Master Pages as the templates and then simply switch the Master Page of the preview page.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Hi ca8msm;

Thanks once again for a good idea. :)

My only concern is that I would have to maintain an html page (for the mailer) as well as the master page (for the preview), synchronising any template changes.

Do you know if there is a way for me to set the html source for an html to be the generated output of a master-detail page combination?

Regards

Sean. [peace]
 
Yes - you can use httpWebRequest and httpWebResponse to request a page and read the resulting HTML.

In your scenario, I'd have something like:

Mailer Page

Contains the code for the mailer and also uses the httpWebRequest and httpWebResponse classes to call the Preview Page (you could maybe pass the name of the template through as a querystring?).

Preview Page

Accepts the body text and template name, merges the two together (by changing the Master Page to that of the template name) and writes out the results.

Does that make sense?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
ca8msm;

You always seem to be the one rescuing me. Do you have a blog site or something? I would love to see what you are up to and what sort of technologies and practices you enjoy. I am sure you have a million tips and tricks up your sleeve.

Your fan,

Sean. [peace]
 
Unfortunately, I don't seem to have the time! I've pretty much created the site that I'd like to use to demonstrate some of the great things you can do with ASP.NET, but I've never got around to publishing it as I'm not sure how up to date I could keep it.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top