Getting Started

There are just a few steps and clicks to integrate and use SharperHTML from your projects.

SharperHTML is for
  1. generation of high quality HTML output to use them wherever you need it and
  2. can be included into ASP.NET and ASP.NET MVC projects or anything else to improve quality of Views and performance of the developement and production stages.

Direct HTML output can be generated standalone, so you can produce HTML wherever you need it (PDF creation, ASP.NET content, etc.). While the inclusion of SharperHTML into a ASP.NET MVC project is additionally supported by a ViewEngine the library provides by default. The ViewEngine must be registered appropriately with just a few characters of code. Both will be shown hereafter.

HTML document output using a .NET API

The only thing you have to prepare is to
  1. set a reference to SharperHTML
    1. set a reference to either the project output or
    2. set a reference to the source project itself within your Visual Studio IDE
  2. include a using statement or use the complete namespaces

// the using statement to include the namespace
using SharperHtml.XHtml1_0Strict;
// create a new HtmlDocument instance
    var doc = new HtmlDocument();
// build the DOM
    doc.Html.head().title("SharperHTML document examples");
    doc.Html.body().div().id("main-div").a("Find details for SharperHtml here").href("http://sharper.codeplex.com");
Now you can create reasults by building the DOM of the HTML document using fluent API of SharperHTML and improve project quality and performance.

Integration with ASP.NET MVC using our ViewEngine

If you intend to replace the default ASP.NET MVC Views with SharperHTML generated Views, you only need to register the ViewEngine provided with the library. In order to do so a registration line of code is needed in the global.asax of the ASP.NET MVC Application.

// registration of of the SharperHTML ViewEngine
    ViewEngines.Engines.Add(new SharperHtmlViewFactory());
Now you can write C# instead of string content to produce Views.

Examples

You can find the most important scenarios in the Quick Start Guide. The nerddinner example project has been altered to show all important aspects of SharperHTML. It is provided with the source code distribution.

(We will provide a step by step introduction to the topics above during the next days)

Last edited Nov 30, 2009 at 6:03 PM by woithe, version 16

Comments

No comments yet.