ASP.NET : XML Viewer for website - asp.net

I have a XML file , that I need to show to the users in readable format i.e in formatting.
how this can be done with ASP.net website.
Any Help

You can use Xml control to perform XSL transformation.

Actipro Software has a great and FREE ASP.NET control that allows you to view XML (and other content) in a syntax highlighted fashion - it's called CodeHighlighter:
(source: actiprosoftware.com)
It's read-only, but if that's good enough for your scenario, it's the best solution around, I think!

Related

Best practice - Generate HTML with XML and XSL in .Net

We have an old ASP.Net application which gets data from a database and generates HTML output to present that data using normal ASP.Net features.
Our customer wants better control of the HTML output, and is therefore suggesting that we store data in XML files, and they deliver and XSL file which transforms the XML into the desired HTML.
The produced HTML contains HTML tables, lists, CSS class references and javascript.
My first thought here is what is the need for ASP.Net then? We cannot avoid using it, as a lot of our code is written in C# and ASP.Net. But are there some issues we should keep in mind, as to why not to choose this method? Does anyone out there have experience doing as we are about to do? Will we meet any dead ends that make us incapable of fulfilling the customers' needs? What about performance for example. All those questions popped to my head when I heard about their request.
Any advice is welcomed here
Thanks
Jihad
If presentation is the only problem, you can use a Jquery type framework with HTML5 and better CSS to improve it. There is no reason to go the XML+ XSLT way.
All you will need to do is to change the style/design on the .aspx pages leaving the .cs pages intact.

ASPX View Engine

So the Razor view engine is open source and can be used outside MVC specific implimentations. However, for my specific project (Where I want to enable this functionality inside WordprocessingML Razor won't work as it tries to be smart and work out what is markup and what is Razor code.
Let me clarify, Razor could work inside WordprocessingML as long as you want to give up the idea of opening and editing the documents in MS Word (Or other openXML compliant editor).
For that reason, I was thinking that if you could encapsulate each line of code in XML tags of some kind, you could overcome that, but that is effectively just the ASPX View Engine.
I think that would work perfectly for what I want to do while supporting the full power of C# if required. The problem is that I don't think the ASPX View Engine is available for direct implimentation.
On the ASP.Net site, Microsoft lists some other view engines like Spark, NHaml, or NDjango.
Have you used these before?
Which would you recommend?
Which would you avoid?
Any other ideas would be much appreciated.
Thanks in advance

Why should I choose Crystal Report or SSRS over plain HTML table?

I am using ASP.NET MVC. Sometimes I work with ASP.NET Web Forms too. I can pretty much create my queries using stored procs or LINQ and render my report just using a plain HTML table. With proper styling it should come out decent.
I don't know SSRS but I have some experience working with crystal from before. The only advantage I see from using crystal for my reports against just a simple HTML table is that it can export to PDF. But I could probably get some third-party library that can do that too. Regarding charts like pie and bar graphs there are a lot of javascript tools available out there that does that and they're free.
I guess I'm posting this to see what I'm missing with reporting tools like Crystal and SSRS.
EDIT: With ASP.NET MVC it is not particularly difficult to create the report. Just formulate the correct model, create the controller action and view with scaffolding (Detail) and you will have the code generated for you right away. With ASP.NET Web Forms it is probably easier, just use a GridView and you're done. For both cases all that is left is the CSS. With Crystal you also need to edit the layout you have generated the report, which is work still as well.
The reason we use SSRS for our internal reports is that our database guy can create reports without having any knowledge of how to format output using code.
your points are valid and I have been thinking about such things multiple times.
Personally I used CR in the past and SSRS more recently, but my absolutely best experience was with DevXpress XtraReports, super cool design and royalty free end user designer with or without Ribboned interface.
the difference between using a report engine or plain raw HTML is in the way you design the reports and the overall features.
in XtraReports for example, the lovely thing is that a report is simply a .cs file (C# class) and whatever you design with the UI designer is stored in that file exactly like the windows forms designer does ( or ASP.NET aspx and aspx.cs designer does ). So you see the report you are designing and you Drag & Drop controls and place them where needed. Then you have out of the box formulas, running totals, page breaks, as you mentioned export to pdf, excel, jpg, html, word and so much more.
if I was free to choice again I would go again for XtraReport and forget about plain and raw html table coding, let's focus on the real business of the application we write and not get nuts with page breaks, exporting things and in house implemented formulas or group/running totals... this is my idea and approach at least.
The biggest reason for me to use a reporting engine is for printing and page breaks. You can't always guarantee the way the HTML will format for all the various browsers and it's not great for setting hard page breaks. With a reporting solution, you can group things together to force page breaks to be more predictable.
This is especially important if you're looking for a more professional looking report.
as already stated above using another report generator can have much benefits. I've used very often List & Label. There is a completely different concept behind and depending on your needs it will be easier but still powerfull, especially for .NET reporting. It is worth to do a trial (there is even a free edition available).

What is a good, free solution for Richtext editor and convertion to HTML?

Simple situation. I'm trying to write my own blog with a minor twist. Part of the blog will be controlled from a client application instead of a web interface. Basically, I'm still in the design phase and haven't written a single line of code. But I'm trying to combine several techniques into an interesting exercise in software development. Thus I want a client application which I can use to write articles in, which can then upload the article through a web service to the server. (The client would be Delphi 2007/WIN32 and the service is ASP.NET/C# with SQL Server.)
The article itself would be stored in RTF format, including images. This would be in a local database on the client, which would also keep track of the article's status. Once uploaded, it will keep the article synchronised with the version on the server. Technical details are just boring and as said before, still in a design phase...
But I do need a good solution to convert the article from RTF in the database to HTML to be displayed in the blog. I have two options:
Upload both the RTF and HTML from the client, with the client doing the convertion from RTF to HTML.
Upload just the RTF and let it convert on demand on the server. (Or convert on the server when the RTF is uploaded.)
Option 1 would need a Delphi/WIN32 solution to convert it while option 2 would need a .NET solution for the conversion. I don't want an RTF editor for .NET but need a good option to use in Delphi 2007. And I need something to convert an RTF to HTML, which would keep (almost) all formatting and which would include all images from the text. This could be both in .NET or Delphi.
So, I have the following questions:
Is there a good, free RTF editor for Delphi which can handle images?
Is there a good RTF-to-HTML converter for Delphi or C# which can keep as much of it's formatting intact as possible, including images?
Some good suggestions for .Net:
Convert Rtf to HTML
Since you provided so much background about why you are doing it, I am going to provide some feedback on the whole plan. This may not be an answer to your question directly though. Sorry.
You might consider looking at Windows Liver Writer for the client. If you just implement an API it supports then it can do all the editing.
Also, I would suggest skipping RTF all together. Converting from RTF to HTML will loose some formatting, and typically create sub-optimal HTML. Creating an RTF with the sole intent of converting to HTML is a less than optimal solution.
Instead keep it HTML for the round trip. If you must use RTF, then limit the RTF formatting to the HTML formatting you want to support. That way the conversion will be more accurate. Then convert as soon as possible, providing a preview for the poster. Since it won't always convert accurately you want the poster to see any of the conversion oddities before they make them public. That way they can fix them before they are embarrassed.
You'd better take a look at TRichEditWB component in EmbeddedWeb component pack. The whole pack is open-source:
http://www.bsalsa.com/forum/forumdisplay.php?f=29
You can add image, and even controls like buttons and checkboxes to TRichEditWB. It also can hilight HTML and XML code, and recognize URLs automatically.

What are the benefits of an XML data model over the DataSet model?

At my current job we have a CMS system that is .NET/SQL Server based. While customizing a couple of the modules for some internal use, I was a little surprised to see that instead of having APIs that returned data via your typical result set that was bound to a DataGrid/DataList/Repeater control, that the APIs returned an XML node/collection, that was then passed to an XSLT transformation and rendered on the page that way.
What are the benefits to using a model like this?
Using XSLT transformations would enable you to use a different layout and formatting than the standard .Net grid controls. Some people don't approve of using the .Net grids because they can include more HTML than necessary, and because if not managed carefully, they can bloat ViewState.
There was a recent discussion here about the .Net grids being bloatware (but developers use them anyway).
The outputted pages can be of any type, like html, php, etc.
By setting up the datasource and xml that the page merely transforms, you have also instantly created a simple 'web service' that can be consumed by other software. For example, it would be trivial to turn that grid into an rss feed or write a program to scrape that data periodically and send a more pressing alert.
The XSLT method is very MVC, unit-testing, separate-concerns friendly where ASP.NET controls well... aren't.
caveat: I reject the assumption that MS can write better html/css/js than I can. ASP.NET controls are clunky abominations.

Resources