views:

99

answers:

2

The goal is to generate some html reports and html emails using templates hosted within the app perhaps using cassini

so the report files will be saved in app_home\Report\Templates*.MyReport file

The app would allow a report (.aspx) page to be selected, loads it using cassini/asp.net hosting api processing some custom markup to populate the data

the resultant html can be viewed in the webbrowser control or can be emailed as html emails

Is there a better way ? Also any pointers on using cassini as such would be great

A: 

It is better to use xslt for such tasks - you can serialize you data model into an xml document then you can transform xml document with an xsl template into html.

Mike
the goal is to offload the template generation to the moderately computer/html literate end user who can format their own reports with says word ergo, xslt won't work
Kumar
A: 

AFAIK you can not distribute Cassini with your apps. There are other desktop webserver, but non of them are 100% compatible with asp.net In my opinion, your solution will be too complicated to implement.

Edit

I learn from this post that

I personally like the StringTemplate option mentioned above, but you can actually host the ASP.NET runtime in a desktop application.

Rick Strahl over at West Wind Technologies has a detailed example of how to set it up: Using the ASP.Net Runtime for extending desktop applications with dynamic HTML Scripts

Here are a couple of other examples:

Other alternatives

Alternative 1

One simple solution would be making simple replacements in the template HTML (using you own processor, and you will be ready to go.

Something like this:

<table>
<tr>
  <th>Name</th>
  <th>Phone</th>
</tr>
<tr>
  <th>$Name</th> <!-- you should run a replace with $Name to the name -->
  <th>$Phone</th>
</tr>

Alternative 2

Use a templating engine like StringTemplate (look for the C# implementation). This CodeProject article is a good intro to the subject

Alternative 3

If you want something more advanced (if your users can take it) I would investigate adding scripting to your app (IronPhyton, IronRuby)

Eduardo Molteni