Professional Documents
Culture Documents
NET MVC
Download class library - 17.19 KB
Download source - 30.94 KB
Introduction
Well, this is my eleventh article. This time, I have tried a new idea about the HTML 5
controls for ASP.NET MVC.
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.
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 Engines
There are two types of view engines in ASP.NET MVC 3. They are ASPX View Engine
and Razor View Engine.
@Html.TextBox("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 <video>, <audio>, <header> and<canvas> elements, 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 <section>, <article>, <header>, and <nav> are 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 <a>, <cite> and <menu> have 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 Application
The 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.
Development
To develop class library for HTML 5 extensions, we need to add reference
of System.Web.Mvc andSystem.Web.WebPages in our application.
Then we need to add this class library in any ASP.NET MVC application.
Name
Description
Html5Helper
Extension
s List
Html5CanvasHelp
er
Extension
s List
Html5SvgHelper
Extension
s List
SourceList
Name
Description
SourceListItem
Extensio
ns
Html5 Extensions
Name
Descrip
tion
Example
PlaceholderBox(Strin
g name, String
placeholderText)
Renders
a input
element
having a
placehol
der text.
@Html.Html5().PlaceholderBox("placeholderBox
1", "Search")
PlaceholderBox(Strin
g name, String
placeholderText,
Object
htmlAttributes)
Renders
a input
element
having a
placehol
der text.
@Html.Html5().PlaceholderBox("placeholderBox
1", "Search", new { @class="txt" })
EmailBox(String
name)
Renders
a input
element
of email
type.
@Html.Html5().EmailBox("emailBox1")
EmailBox(String
name, Object
htmlAttributes)
Renders
a input
element
of email
type.
@Html.Html5().EmailBox("emailBox1", new
{ @class="txt" })
UrlBox(String name)
Renders
a input
element
of url
type.
@Html.Html5().EmailBox("urlBox1")
UrlBox(String name,
Object
htmlAttributes)
Renders
a input
element
of url
type.
@Html.Html5().EmailBox("urlBox1", new
{ @class="txt" })
NumberBox(String
name)
Renders
a input
element
of
number
type.
@Html.Html5().NumberBox("numberBox1")
NumberBox(String
Renders
@Html.Html5().NumberBox("numberBox1", new
Name
Descrip
tion
Example
name, Object
htmlAttributes)
a input
element
of
number
type.
{ @class="txt" })
NumberBox(String
name, double min,
double max, double
step)
Renders
a input
element
of
number
type.
@Html.Html5().NumberBox("numberBox1", 10,
50, 2)
NumberBox(String
name, double min,
double max, double
step, Object
htmlAttributes)
Renders
a input
element
of
number
type.
@Html.Html5().NumberBox("numberBox1", 10,
50, 2, new { @class="txt" })
Range(String name)
Renders
a input
element
of range
type.
@Html.Html5().Range("range1")
Range(String name,
Object
htmlAttributes)
Renders
a input
element
of range
type.
@Html.Html5().Range("range1", new
{ @class="txt" })
Range(String name,
int min, int max, int
step)
Renders
a input
element
of range
type.
Range(String name,
int min, int max, int
step, Object
htmlAttributes)
Renders
a input
element
of range
type.
SearchBox(String
name)
Renders @Html.Html5().SearchBox("searchBox1")
a input
element
of search
type.
SearchBox(String
name, Object
htmlAttributes)
Name
Descrip
tion
Example
ColorBox(String
name)
Renders
a input
element
of color
type.
@Html.Html5().ColorBox("colorBox1")
ColorBox(String
name, Object
htmlAttributes)
Renders
a input
element
of color
type.
@Html.Html5().ColorBox("colorBox1", new
{ @class="txt" })
DateBox(String
name)
Renders
a input
element
of date
type.
@Html.Html5().DateBox("dateBox1")
DateBox(String
name, Object
htmlAttributes)
Renders
a input
element
of date
type.
@Html.Html5().DateBox("dateBox1", new
{ @class="txt" })
MonthBox(String
name)
Renders @Html.Html5().MonthBox("monthBox1")
a input
element
of month
type.
MonthBox(String
name, Object
htmlAttributes)
WeekBox(String
name)
Renders
a input
element
of week
type.
@Html.Html5().WeekBox("weekBox1")
WeekBox(String
name, Object
htmlAttributes)
Renders
a input
element
of week
type.
@Html.Html5().WeekBox("weekBox1", new
{ @class="txt" })
TimeBox(String
name)
Renders
a input
element
of time
type.
@Html.Html5().TimeBox("timeBox1")
TimeBox(String
name, Object
Renders
a input
@Html.Html5().TimeBox("timeBox1", new
{ @class="txt" })
Name
Descrip
tion
Example
htmlAttributes)
element
of time
type.
DateTimeBox(String
name)
Renders @Html.Html5().DateTimeBox("dateTimeBox1")
a input
element
of
datetime
type.
DateTimeBox(String
name, Object
htmlAttributes)
Renders @Html.Html5().DateTimeBox("dateTimeBox1",
a input
new { @class="txt" })
element
of
datetime
type.
Progress(String
name, String
innerText, Object
htmlAttributes)
Progress(String
name, String
innerText, int max)
Progress(String
name, String
innerText, int max,
Object
htmlAttributes)
Progress(String
Renders
@Html.Html5().Progress("progress1", "browser
Name
Descrip
tion
name, String
innerText, int max,
int value)
a
does not support", 500, 300)
progress
element.
Progress(String
name, String
innerText, int max,
int value, Object
htmlAttributes)
Meter(String name,
String innerText)
Meter(String name,
String innerText,
Object
htmlAttributes)
Meter(String name,
String innerText,
double min, double
max, double value)
Meter(String name,
String innerText,
double min, double
max, double value,
Object
htmlAttributes)
Example
Top
Descri
ption
Example
Audio(String name,
String source, String
notSupportedMessage
)
Render @Html.Html5().Media.Audio("audio1","~/audiofile
sa
1.mp3","Browser does not support")
audio
elemen
t in the
client
browse
r.
Audio(String name,
String source, String
notSupportedMessage
, Object
htmlAttributes)
Render @Html.Html5().Media.Audio("audio1","~/audiofile
sa
1.mp3","Browser does not support", new
audio
{ @width="500px", @height="500px"})
elemen
t in the
client
Name
Descri
ption
Example
browse
r.
Audio(String name,
String source, String
notSupportedMessage
, bool showControls,
bool autoPlay, bool
playInLoop)
Render @Html.Html5().Media.Audio("audio1","~/audiofile
sa
1.mp3","Browser does not support", true, true,
audio
true)
elemen
t in the
client
browse
r.
Audio(String name,
String source, String
notSupportedMessage
, bool showControls,
bool autoPlay, bool
playInLoop, Object
htmlAttributes)
Render
sa
audio
elemen
t in the
client
browse
r.
Audio(String name,
IEnumerable<SourceL
istItem> sourceList,
String
notSupportedMessage
)
Audio(String name,
IEnumerable<SourceL
istItem> sourceList,
String
notSupportedMessage
, Object
htmlAttributes)
Render
sa
audio
elemen
t in the
client
browse
r.
Audio(String name,
IEnumerable<SourceL
istItem> sourceList,
String
notSupportedMessage
, bool showControls,
bool autoPlay, bool
playInLoop)
Audio(String name,
IEnumerable<SourceL
istItem> sourceList,
String
notSupportedMessage
, bool showControls,
Render
sa
audio
elemen
t in the
client
browse
@Html.Html5().Media.Audio("audio1","~/audiofile
1.mp3","Browser does not support", true, true,
true, new { @width="500px",
@height="500px"})
@Html.Html5().Media.Audio("audio1", new
SourceList(ViewBag.Sources) ,"Browser does not
support", new { @width="500px",
@height="500px"})
@Html.Html5().Media.Audio("audio1", new
SourceList(ViewBag.Sources) ,"Browser does not
support", true, true, true, new
{ @width="500px", @height="500px"})
Name
Descri
ption
Example
r.
Video(String name,
String source, String
notSupportedMessage
)
Render @Html.Html5().Media.Video("video1","~/videofile
sa
1.mp4","Browser does not support")
video
elemen
t in the
client
browse
r.
Video(String name,
String source, String
notSupportedMessage
, Object
htmlAttributes)
Render @Html.Html5().Media.Video("video1","~/videofile
sa
1.mp4","Browser does not support", new
video
{ @width="500px", @height="500px"})
elemen
t in the
client
browse
r.
Video(String name,
String source, String
notSupportedMessage
, bool showControls,
bool autoPlay, bool
playInLoop)
Render @Html.Html5().Media.Video("video1","~/videofile
sa
1.mp4","Browser does not support", true, true,
video
true)
elemen
t in the
client
browse
r.
Video(String name,
String source, String
notSupportedMessage
, bool showControls,
bool autoPlay, bool
playInLoop, Object
htmlAttributes)
Render
sa
video
elemen
t in the
client
browse
r.
Video(String name,
IEnumerable<SourceL
istItem> sourceList,
String
notSupportedMessage
)
Video(String name,
IEnumerable<SourceL
istItem> sourceList,
String
notSupportedMessage
, Object
Render
sa
video
elemen
t in the
client
@Html.Html5().Media.Video("video1","~/videofile
1.mp4","Browser does not support", true, true,
true, new { @width="500px",
@height="500px"})
@Html.Html5().Media.Video("video1", new
SourceList(ViewBag.Sources) ,"Browser does not
support", new { @width="500px",
@height="500px"})
Name
Descri
ption
Example
htmlAttributes)
browse
r.
Video(String name,
IEnumerable<SourceL
istItem> sourceList,
String
notSupportedMessage
, bool showControls,
bool autoPlay, bool
playInLoop)
Video(String name,
IEnumerable<SourceL
istItem> sourceList,
String
notSupportedMessage
, bool showControls,
bool autoPlay, bool
playInLoop, Object
htmlAttributes)
Render
sa
video
elemen
t in the
client
browse
r.
Video(String name,
IEnumerable<SourceL
istItem>, ObjectType
ObjectType, String
ObjectSource)
Render @Html.Html5().Media.Video("video1",new
sa
SourceList(ViewBag.Sources), ObjectType.Flash,
video
"~/flash1.swf")
elemen
t in the
client
browse
r.
Video(String name,
IEnumerable<SourceL
istItem>, ObjectType
ObjectType, String
ObjectSource, Object
htmlAttributes)
Render
sa
video
elemen
t in the
client
browse
r.
@Html.Html5().Media.Video("video1", new
SourceList(ViewBag.Sources) ,"Browser does not
support", true, true, true, new
{ @width="500px", @height="500px"})
@Html.Html5().Media.Video("video1",new
SourceList(ViewBag.Sources), ObjectType.Flash,
"~/flash1.swf", new { @width="500px",
@height="500px"})
Top
EmptyCanvas(String
name, String
notSupportedMessage)
Descrip
tion
Render
sa
empty
canvas
elemen
Example
@Html.Html5().Canvas.EmptyCanvas("canvas
1", "Browser does not support")
t in the
client
browser
.
EmptyCanvas(String
name, String
notSupportedMessage,
Object htmlAttributes)
Render @Html.Html5().Canvas.EmptyCanvas("canvas
sa
1", "Browser does not support", new
empty
{ @width="500px", @height="500px"})
canvas
elemen
t in the
client
browser
.
Rectangle(String name,
String
notSupportedMessage,
int x, int y, int width, int
height, int thickness,
String lineColor, Object
htmlAttributes)
Render
sa
rectang
le
elemen
t in
canvas
in the
client
browser
.
@Html.Html5().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)
Render
sa
filled
rectang
le
elemen
t in
canvas
in the
client
browser
.
@Html.Html5().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)
Render
sa
ellipse
elemen
t in
canvas
in the
client
browser
.
@Html.Html5().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
Render
sa
filled
ellipse
elemen
t in
@Html.Html5().Canvas.FilledEllipse("canvas1",
"Browser does not support", 100, 100, 200,
150, "#FF0000", new { @width="500px",
@height="500px"})
htmlAttributes)
canvas
in the
client
browser
.
Circle(String name,
String
notSupportedMessage,
int x, int y, float radius,
int thickness, String
lineColor, Object
htmlAttributes)
Render
sa
circle
elemen
t in
canvas
in the
client
browser
.
@Html.Html5().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)
Render
sa
filled
circle
elemen
t in
canvas
in the
client
browser
.
@Html.Html5().Canvas.FilledCircle("canvas1",
"Browser does not support", 100, 200, 75,
"#FF0000", new { @width="500px",
@height="500px"})
Render
s a arc
elemen
t in
canvas
in the
client
browser
.
@Html.Html5().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)
Render
sa
filled
arc
elemen
t in
canvas
in the
client
browser
.
@Html.Html5().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
Render
sa
beizer
curve
elemen
t in
@Html.Html5().Canvas.BeizerCurve("canvas1",
"Browser does not support", 100, 200, 175,
150, 75, 5, "#FF0000", new
{ @width="500px", @height="500px"})
lineColor, Object
htmlAttributes)
canvas
in the
client
browser
.
FilledBeizerCurve(String
name, String
notSupportedMessage,
int x1, int y1, int x2, int
y2, float radius, String
fillColor, Object
htmlAttributes)
Render
sa
filled
beizer
curve
elemen
t in
canvas
in the
client
browser
.
@Html.Html5().Canvas.FilledBeizerCurve("can
vas1", "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)
Render
sa
quadrat
ic curve
elemen
t in
canvas
in the
client
browser
.
@Html.Html5().Canvas.QuadraticCurve("canva
s1", "Browser does not support", 100, 200,
175, 150, 5, "#FF0000", new
{ @width="500px", @height="500px"})
FilledQuadraticCurve(St
ring name, String
notSupportedMessage,
int x1, int y1, int x2, int
y2, String fillColor,
Object htmlAttributes)
Render
sa
filled
quadrat
ic curve
elemen
t in
canvas
in the
client
browser
.
@Html.Html5().Canvas.FilledQuadraticCurve("c
anvas1", "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)
Render
sa
polygon
elemen
t in
canvas
in the
client
browser
.
@Html.Html5().Canvas.Polygon("canvas1",
"Browser does not support", ViewBag.Points, 5,
"#FF0000", new { @width="500px",
@height="500px"})
FilledPolygon(String
name, String
Render
sa
@Html.Html5().Canvas.FilledPolygon("canvas1
", "Browser does not support", ViewBag.Points,
notSupportedMessage,
Point[] points, String
fillColor, Object
htmlAttributes)
filled
"#FF0000", new { @width="500px",
polygon @height="500px"})
elemen
t in
canvas
in the
client
browser
.
Render
s a text
elemen
t in
canvas
in the
client
browser
.
-@Html.Html5().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)
Render
sa
filled
text
elemen
t in
canvas
in the
client
browser
.
@Html.Html5().Canvas.FilledText("canvas1",
"Browser does not support", 200, 300,
"CodeProject", "Tahoma", 35, "bold",
"#FF0000", new { @width="500px",
@height="500px"})
Render
s a line
elemen
t in
canvas
in the
client
browser
.
@Html.Html5().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)
Render
sa
image
elemen
t in
canvas
in the
client
browser
.
@Html.Html5().Canvas.Image("canvas1",
"Browser does not support", 50, 50, 250, 250,
"~/imagefile1.jpg", new { @width="500px",
@height="500px"})
Top
Name
Descripti
on
Example
Renders a @Html.Html5().Svg.EmptySvg("svg1",
empty
"Browser does not support", new
svg
{ @width="500px", @height="500px"})
element
in the
client
browser.
Rectangle(String name,
String
notSupportedMessage,
int x, int y, int width, int
height, int thickness,
String lineColor, Object
htmlAttributes)
Renders a
svg
element
containin
ga
rectangle
in the
client
browser.
@Html.Html5().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
containin
g a filled
rectangle
in the
client
browser.
@Html.Html5().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
containin
ga
ellipse in
the client
browser.
@Html.Html5().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
containin
g a filled
ellipse in
the client
browser.
@Html.Html5().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)
svg
element
containin
g a circle
in the
client
browser.
FilledCircle(String
name, String
notSupportedMessage,
int cx, int cy, float
radius, String fillColor,
Object htmlAttributes)
Renders a
svg
element
containin
g a filled
circle in
the client
browser.
@Html.Html5().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
containin
ga
polygon
in the
client
browser.
@Html.Html5().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
containin
g a filled
polygon
in the
client
browser.
@Html.Html5().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
containin
g a text
in the
client
browser.
@Html.Html5().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
Renders a
svg
element
containin
g a filled
text in
the client
@Html.Html5().Svg.FilledText("svg1",
"Browser does not support", 100, 150,
"CodeProject", "Tahoma", 35, "bold", "italic",
"underline", "#FF0000", new
{ @width="500px", @height="500px"})
fontStyle, String
textDecoration, String
fillColor, Object
htmlAttributes)
browser.
Line(String name,
String
notSupportedMessage,
int x1, int y1, int x2, int
y2, int thickness, String
lineColor, Object
htmlAttributes)
Renders a
svg
element
containin
g a line in
the client
browser.
@Html.Html5().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
containin
ga
polyline
in the
client
browser.
@Html.Html5().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
containin
g a image
in the
client
browser.
@Html.Html5().Svg.Image("svg1", "Browser
does not support", 50, 50, 300, 300,
"~/imagefile1.jpg", new { @width="500px",
@height="500px"})
Top
Copy Code
{
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