class library for html 5 controls for asp

23
 Class Library for HTML 5 controls for ASP.NET MVC  Download class library - 17.19 KB  Download sour ce - 30.94 KB Introduction Well t!is is "y ele#ent! article. T!is ti"e I !a#e tried a ne$ idea about t!e HTML 5 controls for ASP.NET MVC. W!at is ASP.NET MVC% ASP.NET MVC is a &art of t!e ASP.NET Web a&&lication fra"e$or'. It is one of t!e t$o di(erent &ro)ra""in) "odels you can use to create ASP.NET Web a&&lications t!e ot!er bein) ASP.NET Web *or"s. An MVC A&&lication is desi)ned and i"&le"ented usin) t!e follo$in) t!ree attributes+ Model: T!e "odel contains t!e core infor"ation for an a&&lication. T!is includes t!e data and #alidation rules as $ell as data access and a))re)a tion lo)ic. View: T!e #ie$ enca&sulates t!e &resentation of t!e a&&lication and in ASP.NET t!is is ty&ically t!e HTML "ar'u&. Controller: T!e controller contains t!e control,-o$ lo)ic. It interacts $it! t!e Model and Vie$s to control t!e -o$ of infor"ation and eecution of t!e a&&lication.  T!is se&arat ion of entity allo$s you t o !a#e ni"bleness and -eib ility in buildin) and "aintainin) your a&&lication. *or ea"&le by se&aratin) t!e #ie$s you can iterate on t!e a&&earance of your a&&lication $it!out touc!in) on any of t!e core business lo)ic. /ou can also se&arate $or' by role so t!at for ea"&le desi)ners can $or' on t!e #ie$s $!ile de#elo&ers $or' on t!e "odel.

Upload: tbijle

Post on 03-Nov-2015

235 views

Category:

Documents


0 download

DESCRIPTION

Class Library for HTML 5 Controls for AS

TRANSCRIPT

Class Library for HTML 5 controls for ASP.NET MVC Download class library - 17.19 KB Download source- 30.94 KBIntroductionWell, this is my eleventh article. This time, I have tried a new idea about the HTML 5 controls for ASP.NET MVC.What is ASP.NET MVC?ASP.NET MVC is a part of the ASP.NET Web application framework. It is one of the two different programming models you can use to create ASP.NET Web applications, the other being ASP.NET Web Forms.An MVC Application is designed and implemented using the following three attributes:

Model:The model contains the core information for an application. This includes the data and validation rules as well as data access and aggregation logic. View:The view encapsulates the presentation of the application, and in ASP.NET this is typically the HTML markup. Controller:The controller contains the control-flow logic. It interacts with the Model and Views to control the flow of information and execution of the application.This separation of entity allows you to have nimbleness and flexibility in building and maintaining your application. For example, by separating the views, you can iterate on the appearance of your application without touching on any of the core business logic. You can also separate work by role, so that, for example designers can work on the views, while developers work on the model.ASP.NET MVC brings the power of this development paradigm to ASP.NET development, allowing you to use your .NET development skills to build MVC applications.It: gives you complete control over your HTML Markup enables rich AJAX and jQuery integration allows you to create SEO-friendly URLs for your site makes Test Driven Development (TDD) easyWhat is a Model View Controller (MVC) Framework?MVC is a framework methodology that divides an application's implementation into three component roles: models, views, and controllers. "Models" in a MVC based application are the components of the application that are responsible for maintaining state. Often this state is persisted inside a database (for example: we might have aProductclass that is used to represent order data from theProductstable inside SQL). "Views" in a MVC based application are the components responsible for displaying the application's user interface. Typically, this UI is created off of the model data (for example: we might create anProduct"Edit" view that surfaces textboxes, dropdowns and checkboxes based on the current state of aProductobject). "Controllers" in a MVC based application are the components responsible for handling end user interaction, manipulating the model, and ultimately choosing a view to render to display UI. In an MVC application, the view is only about displaying information - it is the controller that handles and responds to user input and interaction.One of the benefits of using a MVC methodology is that it helps enforce a clean separation of concerns between the models, views and controllers within an application. Maintaining a clean separation of concerns makes the testing of applications much easier, since the contract between different application components are more clearly defined and articulated.What is ASP.Net MVC? (Definition from Wikipedia)The ASP.NET MVC Framework is a web application framework that implements the model-view-controller pattern. Based on ASP.NET, it allows software developers to build a Web application as a composition of three roles: Model, View and Controller. A model represents the state of a particular aspect of the application. Frequently, a model maps to a database table with the entries in the table representing the state of the application. A controller handles interactions and updates the model to reflect a change in state of the application, and then passes information to the view. A view accepts necessary information from the controller and renders a user interface to display that.In April 2009, the ASP.NET MVC source code was released under the Microsoft Public License (MS-PL).The ASP.NET MVC Framework couples the models, views, and controllers using interface-based contracts, thereby allowing each component to be easily tested independently.View EnginesThere are two types of view engines in ASP.NET MVC 3. They are ASPX View Engine and Razor View Engine.ASPX View EngineHideCopy Code

Razor View EngineHideCopy [email protected]("txtBox")What is HTML 5?HTML5 is a language for structuring and presenting content for the World Wide Web, a core technology of the Internet. It is the fifth revision of the HTML standard (originally created in 1990 and most recently standardized as HTML4 in 1997) and as of August 2011 is still under development. Its core aims have been to improve the language with support for the latest multimedia while keeping it easily readable by humans and consistently understood by computers and devices (web browsers, parsers, etc.). HTML5 is intended to subsume not only HTML4, but XHTML1 and DOM2HTML (particularly JavaScript) as well.Following its immediate predecessors HTML 4.01 and XHTML 1.1, HTML5 is a response to the observation that the HTML and XHTML in common use on the World Wide Web is a mixture of features introduced by various specifications, along with those introduced by software products such as web browsers, those established by common practice, and the many syntax errors in existing web documents. It is also an attempt to define a single markup language that can be written in either HTML or XHTML syntax. It includes detailed processing models to encourage more interoperable implementations; it extends, improves and rationalises the markup available for documents, and introduces markup and APIs for complex web applications.In particular, HTML5 adds many new syntactical features. These include the,,andelements, as well as the integration of SVG content. These features are designed to make it easy to include and handle multimedia and graphical content on the web without having to resort to proprietary plugins and APIs. Other new elements, such as,,, andare designed to enrich the semantic content of documents. New attributes have been introduced for the same purpose, while some elements and attributes have been removed. Some elements, such as,andhave been changed, redefined or standardised. The APIs and DOM are no longer afterthoughts, but are fundamental parts of the HTML5 specification. HTML5 also defines in some detail the required processing for invalid documents, so that syntax errors will be treated uniformly by all conforming browsers and other user agents.Our ApplicationThe purpose of our application is to use HTML 5 controls for ASP.NET MVC whether ASPX Engine or Razor Engine. After doing some analysis is developed this class library, but anyhow I was not able to implement some tags and options through this class library, I have made with some limitations.DevelopmentTo develop class library for HTML 5 extensions, we need to add reference ofSystem.Web.MvcandSystem.Web.WebPagesin our application.

Then we need to add this class library in any ASP.NET MVC application.

List of Classes and ExtensionsNameDescriptionExtensions

Html5HelperA Html5 helper class which contains all the Html5 elements.Extensions List

Html5MediaHelperA Html5 helper class which contains all the media related elements.Extensions List

Html5CanvasHelperA Html5 helper class which contains all the canvas related elements.Extensions List

Html5SvgHelperA Html5 helper class which contains all the svg related elements.Extensions List

SourceListRepresents a list that contains all the source items.

SourceListItemRepresents the source item in an instance of theSystem.Web.Mvc.SourceListItemclass.

Html5 ExtensionsNameDescriptionExample

PlaceholderBox(String name, String placeholderText)Renders a input element having a placeholder [email protected]().PlaceholderBox("placeholderBox1", "Search")

PlaceholderBox(String name, String placeholderText, Object htmlAttributes)Renders a input element having a placeholder [email protected]().PlaceholderBox("placeholderBox1", "Search", new { @class="txt" })

EmailBox(String name)Renders a input element of email [email protected]().EmailBox("emailBox1")

EmailBox(String name, Object htmlAttributes)Renders a input element of email [email protected]().EmailBox("emailBox1", new { @class="txt" })

UrlBox(String name)Renders a input element of url [email protected]().EmailBox("urlBox1")

UrlBox(String name, Object htmlAttributes)Renders a input element of url [email protected]().EmailBox("urlBox1", new { @class="txt" })

NumberBox(String name)Renders a input element of number [email protected]().NumberBox("numberBox1")

NumberBox(String name, Object htmlAttributes)Renders a input element of number [email protected]().NumberBox("numberBox1", new { @class="txt" })

NumberBox(String name, double min, double max, double step)Renders a input element of number [email protected]().NumberBox("numberBox1", 10, 50, 2)

NumberBox(String name, double min, double max, double step, Object htmlAttributes)Renders a input element of number [email protected]().NumberBox("numberBox1", 10, 50, 2, new { @class="txt" })

Range(String name)Renders a input element of range [email protected]().Range("range1")

Range(String name, Object htmlAttributes)Renders a input element of range [email protected]().Range("range1", new { @class="txt" })

Range(String name, int min, int max, int step)Renders a input element of range [email protected]().Range("range1", 10, 50, 2)

Range(String name, int min, int max, int step, Object htmlAttributes)Renders a input element of range [email protected]().Range("range1", 10, 50, 2, new { @class="txt" })

SearchBox(String name)Renders a input element of search [email protected]().SearchBox("searchBox1")

SearchBox(String name, Object htmlAttributes)Renders a input element of search [email protected]().SearchBox("searchBox1", new { @class="txt" })

ColorBox(String name)Renders a input element of color [email protected]().ColorBox("colorBox1")

ColorBox(String name, Object htmlAttributes)Renders a input element of color [email protected]().ColorBox("colorBox1", new { @class="txt" })

DateBox(String name)Renders a input element of date [email protected]().DateBox("dateBox1")

DateBox(String name, Object htmlAttributes)Renders a input element of date [email protected]().DateBox("dateBox1", new { @class="txt" })

MonthBox(String name)Renders a input element of month [email protected]().MonthBox("monthBox1")

MonthBox(String name, Object htmlAttributes)Renders a input element of month [email protected]().MonthBox("monthBox1", new { @class="txt" })

WeekBox(String name)Renders a input element of week [email protected]().WeekBox("weekBox1")

WeekBox(String name, Object htmlAttributes)Renders a input element of week [email protected]().WeekBox("weekBox1", new { @class="txt" })

TimeBox(String name)Renders a input element of time [email protected]().TimeBox("timeBox1")

TimeBox(String name, Object htmlAttributes)Renders a input element of time [email protected]().TimeBox("timeBox1", new { @class="txt" })

DateTimeBox(String name)Renders a input element of datetime [email protected]().DateTimeBox("dateTimeBox1")

DateTimeBox(String name, Object htmlAttributes)Renders a input element of datetime [email protected]().DateTimeBox("dateTimeBox1", new { @class="txt" })

DateTimeLocalBox(String name)Renders a input element of datetime-local [email protected]().DateTimeLocalBox("dateTimeLocalBox1")

DateTimeLocalBox(String name, Object htmlAttributes)Renders a input element of datetime-local [email protected]().DateTimeLocalBox("dateTimeLocalBox1", new { @class="txt" })

Progress(String name, String innerText)Renders a progress [email protected]().Progress("progress1", "browser does not support")

Progress(String name, String innerText, Object htmlAttributes)Renders a progress [email protected]().Progress("progress1", "browser does not support", new { @class="txt" })

Progress(String name, String innerText, int max)Renders a progress [email protected]().Progress("progress1", "browser does not support", 500)

Progress(String name, String innerText, int max, Object htmlAttributes)Renders a progress [email protected]().Progress("progress1", "browser does not support", 500, new { @class="txt" })

Progress(String name, String innerText, int max, int value)Renders a progress [email protected]().Progress("progress1", "browser does not support", 500, 300)

Progress(String name, String innerText, int max, int value, Object htmlAttributes)Renders a progress [email protected]().Progress("progress1", "browser does not support", 500, 300, new { @class="txt" })

Meter(String name, String innerText)Renders a meter [email protected]().Meter("meter1", "browser does not support")

Meter(String name, String innerText, Object htmlAttributes)Renders a meter [email protected]().Meter("meter1", "browser does not support", new { @class="txt" })

Meter(String name, String innerText, double min, double max, double value)Renders a meter [email protected]().Meter("meter1", "browser does not support", 100, 500, 200)

Meter(String name, String innerText, double min, double max, double value, Object htmlAttributes)Renders a meter [email protected]().Meter("meter1", "browser does not support", 100, 500, 200, new { @class="txt" })

TopHtml5 Media ExtensionsNameDescriptionExample

Audio(String name, String source, String notSupportedMessage)Renders a audio element in the client [email protected]().Media.Audio("audio1","~/audiofile1.mp3","Browser does not support")

Audio(String name, String source, String notSupportedMessage, Object htmlAttributes)Renders a audio element in the client [email protected]().Media.Audio("audio1","~/audiofile1.mp3","Browser does not support", new { @width="500px", @height="500px"})

Audio(String name, String source, String notSupportedMessage, bool showControls, bool autoPlay, bool playInLoop)Renders a audio element in the client [email protected]().Media.Audio("audio1","~/audiofile1.mp3","Browser does not support", true, true, true)

Audio(String name, String source, String notSupportedMessage, bool showControls, bool autoPlay, bool playInLoop, Object htmlAttributes)Renders a audio element in the client [email protected]().Media.Audio("audio1","~/audiofile1.mp3","Browser does not support", true, true, true, new { @width="500px", @height="500px"})

Audio(String name, IEnumerable sourceList, String notSupportedMessage)Renders a audio element in the client [email protected]().Media.Audio("audio1", new SourceList(ViewBag.Sources) ,"Browser does not support")

Audio(String name, IEnumerable sourceList, String notSupportedMessage, Object htmlAttributes)Renders a audio element in the client [email protected]().Media.Audio("audio1", new SourceList(ViewBag.Sources) ,"Browser does not support", new { @width="500px", @height="500px"})

Audio(String name, IEnumerable sourceList, String notSupportedMessage, bool showControls, bool autoPlay, bool playInLoop)Renders a audio element in the client [email protected]().Media.Audio("audio1", new SourceList(ViewBag.Sources) ,"Browser does not support", true, true, true)

Audio(String name, IEnumerable sourceList, String notSupportedMessage, bool showControls, bool autoPlay, bool playInLoop, Object htmlAttributes)Renders a audio element in the client [email protected]().Media.Audio("audio1", new SourceList(ViewBag.Sources) ,"Browser does not support", true, true, true, new { @width="500px", @height="500px"})

Video(String name, String source, String notSupportedMessage)Renders a video element in the client [email protected]().Media.Video("video1","~/videofile1.mp4","Browser does not support")

Video(String name, String source, String notSupportedMessage, Object htmlAttributes)Renders a video element in the client [email protected]().Media.Video("video1","~/videofile1.mp4","Browser does not support", new { @width="500px", @height="500px"})

Video(String name, String source, String notSupportedMessage, bool showControls, bool autoPlay, bool playInLoop)Renders a video element in the client [email protected]().Media.Video("video1","~/videofile1.mp4","Browser does not support", true, true, true)

Video(String name, String source, String notSupportedMessage, bool showControls, bool autoPlay, bool playInLoop, Object htmlAttributes)Renders a video element in the client [email protected]().Media.Video("video1","~/videofile1.mp4","Browser does not support", true, true, true, new { @width="500px", @height="500px"})

Video(String name, IEnumerable sourceList, String notSupportedMessage)Renders a video element in the client [email protected]().Media.Video("video1", new SourceList(ViewBag.Sources) ,"Browser does not support")

Video(String name, IEnumerable sourceList, String notSupportedMessage, Object htmlAttributes)Renders a video element in the client [email protected]().Media.Video("video1", new SourceList(ViewBag.Sources) ,"Browser does not support", new { @width="500px", @height="500px"})

Video(String name, IEnumerable sourceList, String notSupportedMessage, bool showControls, bool autoPlay, bool playInLoop)Renders a video element in the client [email protected]().Media.Video("video1", new SourceList(ViewBag.Sources) ,"Browser does not support", true, true, true)

Video(String name, IEnumerable sourceList, String notSupportedMessage, bool showControls, bool autoPlay, bool playInLoop, Object htmlAttributes)Renders a video element in the client [email protected]().Media.Video("video1", new SourceList(ViewBag.Sources) ,"Browser does not support", true, true, true, new { @width="500px", @height="500px"})

Video(String name, IEnumerable, ObjectType ObjectType, String ObjectSource)Renders a video element in the client [email protected]().Media.Video("video1",new SourceList(ViewBag.Sources), ObjectType.Flash, "~/flash1.swf")

Video(String name, IEnumerable, ObjectType ObjectType, String ObjectSource, Object htmlAttributes)Renders a video element in the client [email protected]().Media.Video("video1",new SourceList(ViewBag.Sources), ObjectType.Flash, "~/flash1.swf", new { @width="500px", @height="500px"})

TopHtml5 Canvas ExtensionsNameDescriptionExample

EmptyCanvas(String name, String notSupportedMessage)Renders a empty canvas element in the client [email protected]().Canvas.EmptyCanvas("canvas1", "Browser does not support")

EmptyCanvas(String name, String notSupportedMessage, Object htmlAttributes)Renders a empty canvas element in the client [email protected]().Canvas.EmptyCanvas("canvas1", "Browser does not support", new { @width="500px", @height="500px"})

Rectangle(String name, String notSupportedMessage, int x, int y, int width, int height, int thickness, String lineColor, Object htmlAttributes)Renders a rectangle element in canvas in the client [email protected]().Canvas.Rectangle("canvas1", "Browser does not support", 100, 100, 200, 150, 4, "#FF0000", new { @width="500px", @height="500px"})

FilledRectangle(String name, String notSupportedMessage, int x, int y, int width, int height, String fillColor, Object htmlAttributes)Renders a filled rectangle element in canvas in the client [email protected]().Canvas.Rectangle("canvas1", "Browser does not support", 100, 100, 200, 150, "#FF0000", new { @width="500px", @height="500px"})

Ellipse(String name, String notSupportedMessage, int cx, int cy, int width, int height, int thickness, String lineColor, Object htmlAttributes)Renders a ellipse element in canvas in the client [email protected]().Canvas.Ellipse("canvas1", "Browser does not support", 100, 100, 200, 150, 4, "#FF0000", new { @width="500px", @height="500px"})

FilledEllipse(String name, String notSupportedMessage, int cx, int cy, int width, int height, String fillColor, Object htmlAttributes)Renders a filled ellipse element in canvas in the client [email protected]().Canvas.FilledEllipse("canvas1", "Browser does not support", 100, 100, 200, 150, "#FF0000", new { @width="500px", @height="500px"})

Circle(String name, String notSupportedMessage, int x, int y, float radius, int thickness, String lineColor, Object htmlAttributes)Renders a circle element in canvas in the client [email protected]().Canvas.Circle("canvas1", "Browser does not support", 100, 200, 75, 4, "#FF0000", new { @width="500px", @height="500px"})

FilledCircle(String name, String notSupportedMessage, int x, int y, float radius, String fillColor, Object htmlAttributes)Renders a filled circle element in canvas in the client [email protected]().Canvas.FilledCircle("canvas1", "Browser does not support", 100, 200, 75, "#FF0000", new { @width="500px", @height="500px"})

Arc(String name, String notSupportedMessage, int x, int y, float radius, int thickness, float startAngle, float endAngle, String lineColor, Object htmlAttributes)Renders a arc element in canvas in the client [email protected]().Canvas.Arc("canvas1", "Browser does not support", 100, 200, 75, 5, 150, 250, "#FF0000", new { @width="500px", @height="500px"})

FilledArc(String name, String notSupportedMessage, int x, int y, float radius, float startAngle, float endAngle, String fillColor, Object htmlAttributes)Renders a filled arc element in canvas in the client [email protected]().Canvas.FilledArc("canvas1", "Browser does not support", 100, 200, 75, 150, 250, "#FF0000", new { @width="500px", @height="500px"})

BeizerCurve(String name, String notSupportedMessage, int x1, int y1, int x2, int y2, float radius, int thickness, String lineColor, Object htmlAttributes)Renders a beizer curve element in canvas in the client [email protected]().Canvas.BeizerCurve("canvas1", "Browser does not support", 100, 200, 175, 150, 75, 5, "#FF0000", new { @width="500px", @height="500px"})

FilledBeizerCurve(String name, String notSupportedMessage, int x1, int y1, int x2, int y2, float radius, String fillColor, Object htmlAttributes)Renders a filled beizer curve element in canvas in the client [email protected]().Canvas.FilledBeizerCurve("canvas1", "Browser does not support", 100, 200, 175, 150, 75, "#FF0000", new { @width="500px", @height="500px"})

QuadraticCurve(String name, String notSupportedMessage, int x1, int y1, int x2, int y2, int thickness, String lineColor, Object htmlAttributes)Renders a quadratic curve element in canvas in the client [email protected]().Canvas.QuadraticCurve("canvas1", "Browser does not support", 100, 200, 175, 150, 5, "#FF0000", new { @width="500px", @height="500px"})

FilledQuadraticCurve(String name, String notSupportedMessage, int x1, int y1, int x2, int y2, String fillColor, Object htmlAttributes)Renders a filled quadratic curve element in canvas in the client [email protected]().Canvas.FilledQuadraticCurve("canvas1", "Browser does not support", 100, 200, 175, 150, "#FF0000", new { @width="500px", @height="500px"})

Polygon(String name, String notSupportedMessage, Point[] points, int thickness, String lineColor, Object htmlAttributes)Renders a polygon element in canvas in the client [email protected]().Canvas.Polygon("canvas1", "Browser does not support", ViewBag.Points, 5, "#FF0000", new { @width="500px", @height="500px"})

FilledPolygon(String name, String notSupportedMessage, Point[] points, String fillColor, Object htmlAttributes)Renders a filled polygon element in canvas in the client [email protected]().Canvas.FilledPolygon("canvas1", "Browser does not support", ViewBag.Points, "#FF0000", new { @width="500px", @height="500px"})

Text(String name, String notSupportedMessage, int x, int y, String text, String fontFamily, int fontSize, String fontStyle, int thickness, String lineColor, Object htmlAttributes)Renders a text element in canvas in the client [email protected]().Canvas.Text("canvas1", "Browser does not support", 200, 300, "CodeProject", "Tahoma", 35, "bold", 5, "#FF0000", new { @width="500px", @height="500px"})

FilledText(String name, String notSupportedMessage, int x, int y, String text, String fontFamily, int fontSize, String fontStyle, String fillColor, Object htmlAttributes)Renders a filled text element in canvas in the client [email protected]().Canvas.FilledText("canvas1", "Browser does not support", 200, 300, "CodeProject", "Tahoma", 35, "bold", "#FF0000", new { @width="500px", @height="500px"})

Line(String name, String notSupportedMessage, int x1, int y1, int x2, int y2, int thickness, String lineColor, Object htmlAttributes)Renders a line element in canvas in the client [email protected]().Canvas.Line("canvas1", "Browser does not support", 200, 300, 400, 450, 5, "#FF0000", new { @width="500px", @height="500px"})

Image(String name, String notSupportedMessage, int x, int y, int width, int height, String imageUrl, Object htmlAttributes)Renders a image element in canvas in the client [email protected]().Canvas.Image("canvas1", "Browser does not support", 50, 50, 250, 250, "~/imagefile1.jpg", new { @width="500px", @height="500px"})

TopHtml5 Svg ExtensionsNameDescriptionExample

EmptySvg(String name, String notSupportedMessage)Renders a empty svg element in the client [email protected]().Svg.EmptySvg("svg1", "Browser does not support")

EmptySvg(String name, String notSupportedMessage, Object htmlAttributes)Renders a empty svg element in the client [email protected]().Svg.EmptySvg("svg1", "Browser does not support", new { @width="500px", @height="500px"})

Rectangle(String name, String notSupportedMessage, int x, int y, int width, int height, int thickness, String lineColor, Object htmlAttributes)Renders a svg element containing a rectangle in the client [email protected]().Svg.Rectangle("svg1", "Browser does not support", 200, 300, 300, 200, 5, "#FF0000", new { @width="500px", @height="500px"})

FilledRectangle(String name, String notSupportedMessage, int x, int y, int width, int height, String fillColor, Object htmlAttributes)Renders a svg element containing a filled rectangle in the client [email protected]().Svg.FilledRectangle("svg1", "Browser does not support", 200, 300, 300, 200, "#FF0000", new { @width="500px", @height="500px"})

Ellipse(String name, String notSupportedMessage, int cx, int cy, int width, int height, int thickness, String lineColor, Object htmlAttributes)Renders a svg element containing a ellipse in the client [email protected]().Svg.Ellipse("svg1", "Browser does not support", 200, 300, 300, 200, 5, "#FF0000", new { @width="500px", @height="500px"})

FilledEllipse(String name, String notSupportedMessage, int cx, int cy, int width, int height, String fillColor, Object htmlAttributes)Renders a svg element containing a filled ellipse in the client [email protected]().Svg.FilledEllipse("svg1", "Browser does not support", 200, 300, 300, 200, "#FF0000", new { @width="500px", @height="500px"})

Circle(String name, String notSupportedMessage, int cx, int cy, float radius, int thickness, String lineColor, Object htmlAttributes)Renders a svg element containing a circle in the client [email protected]().Svg.Circle("svg1", "Browser does not support", 200, 300, 75, 5, "#FF0000", new { @width="500px", @height="500px"})

FilledCircle(String name, String notSupportedMessage, int cx, int cy, float radius, String fillColor, Object htmlAttributes)Renders a svg element containing a filled circle in the client [email protected]().Svg.FilledCircle("svg1", "Browser does not support", 200, 300, 75, "#FF0000", new { @width="500px", @height="500px"})

Polygon(String name, String notSupportedMessage, Point[] points, int thickness, String lineColor, Object htmlAttributes)Renders a svg element containing a polygon in the client [email protected]().Svg.Polygon("svg1", "Browser does not support", ViewBag.Points, 5, "#FF0000", new { @width="500px", @height="500px"})

FilledPolygon(String name, String notSupportedMessage, Point[] points, String fillColor, Object htmlAttributes)Renders a svg element containing a filled polygon in the client [email protected]().Svg.FilledPolygon("svg1", "Browser does not support", ViewBag.Points, "#FF0000", new { @width="500px", @height="500px"})

Text(String name, String notSupportedMessage, int x, int y, String text, String fontFamily, int fontSize, String fontWeight, String fontStyle, String textDecoration, int thickness, String lineColor, Object htmlAttributes)Renders a svg element containing a text in the client [email protected]().Svg.Text("svg1", "Browser does not support", 100, 150, "CodeProject", "Tahoma", 35, "bold", "italic", "underline", 5, "#FF0000", new { @width="500px", @height="500px"})

FilledText(String name, String notSupportedMessage, int x, int y, String text, String fontFamily, int fontSize, String fontWeight, String fontStyle, String textDecoration, String fillColor, Object htmlAttributes)Renders a svg element containing a filled text in the client [email protected]().Svg.FilledText("svg1", "Browser does not support", 100, 150, "CodeProject", "Tahoma", 35, "bold", "italic", "underline", "#FF0000", new { @width="500px", @height="500px"})

Line(String name, String notSupportedMessage, int x1, int y1, int x2, int y2, int thickness, String lineColor, Object htmlAttributes)Renders a svg element containing a line in the client [email protected]().Svg.Line("svg1", "Browser does not support", 100, 150, 300, 400, 5, "#FF0000", new { @width="500px", @height="500px"})

PolyLine(String name, String notSupportedMessage, Point[] points, int thickness, String lineColor, Object htmlAttributes)Renders a svg element containing a polyline in the client [email protected]().Svg.PolyLine("svg1", "Browser does not support", ViewBag.Points, 5, "#FF0000", new { @width="500px", @height="500px"})

Image(String name, String notSupportedMessage, int x, int y, int width, int height, String imageUrl, Object htmlAttributes)Renders a svg element containing a image in the client [email protected]().Svg.Image("svg1", "Browser does not support", 50, 50, 300, 300, "~/imagefile1.jpg", new { @width="500px", @height="500px"})

TopSamples of Usage of the Class Library

Small Piece of CodeHideShrinkCopy Code//Creating input elements of different input type.private TagBuilder BuildInputTag(string name, string inputType, object htmlAttributes){ TagBuilder tagBuilder = new TagBuilder("input"); if (htmlAttributes != null) { RouteValueDictionary routeValueDictionary = new RouteValueDictionary(htmlAttributes); tagBuilder.MergeAttributes(routeValueDictionary); } tagBuilder.MergeAttribute("type", inputType); tagBuilder.MergeAttribute("name", name); tagBuilder.MergeAttribute("id", name); return tagBuilder;}//Creating video elementpublic MvcHtmlString Video(string name, IEnumerable sourceList, ObjectType objectType, string objectSource, object htmlAttributes){ TagBuilder tagBuilder = new TagBuilder("video"); if (htmlAttributes != null) { RouteValueDictionary routeValueDictionary = new RouteValueDictionary(htmlAttributes); tagBuilder.MergeAttributes(routeValueDictionary); } tagBuilder.MergeAttribute("id", name); StringBuilder sourceItemBuilder = new StringBuilder(); sourceItemBuilder.AppendLine(); foreach (var sourceItem in sourceList) { sourceItemBuilder.AppendLine(SourceItemToSource(sourceItem)); } sourceItemBuilder.AppendLine(); if (objectType == ObjectType.Flash) { sourceItemBuilder.AppendLine(CreateFlashObject(objectSource, htmlAttributes)); } else { sourceItemBuilder.AppendLine(CreateSilverlightObject(sourceList, objectSource, htmlAttributes)); } tagBuilder.InnerHtml = sourceItemBuilder.ToString(); sourceItemBuilder.AppendLine(); return MvcHtmlString.Create(tagBuilder.ToString(TagRenderMode.Normal));}//Creating canvas elementpublic MvcHtmlString EmptyCanvas(string name, string notSupportedMessage, object htmlAttributes){ TagBuilder tagBuilder = new TagBuilder("canvas"); if (htmlAttributes != null) { RouteValueDictionary routeValueDictionary = new RouteValueDictionary(htmlAttributes); tagBuilder.MergeAttributes(routeValueDictionary); } tagBuilder.MergeAttribute("id", name); tagBuilder.InnerHtml = notSupportedMessage; return MvcHtmlString.Create(tagBuilder.ToString(TagRenderMode.Normal));}//Creating svg elementprivate static TagBuilder CreateSvgTag(string name, string notSupportedMessage, object htmlAttributes){ TagBuilder tagBuilder = new TagBuilder("svg"); if (htmlAttributes != null) { RouteValueDictionary routeValueDictionary = new RouteValueDictionary(htmlAttributes); tagBuilder.MergeAttributes(routeValueDictionary); } tagBuilder.MergeAttribute("xmlns", "http://www.w3.org/2000/svg"); tagBuilder.MergeAttribute("id", name); tagBuilder.InnerHtml = notSupportedMessage; return tagBuilder;}Demo