TUTORIAL HTML : HTML Helpers







Sample of the pdf document : 



Understanding HTML Helpers:

An HTML Helper is just a method that returns a string. The string can represent any type of
content that you want. For example, you can use HTML Helpers to render standard HTML
tags like HTML <input> and <img> tags. You also can use HTML Helpers to render more
complex content such as a tab strip or an HTML table of database data.

The ASP.NET MVC framework includes the following set of standard HTML Helpers (this is
not a complete list):


• Html.ActionLink()
• Html.BeginForm()
• Html.CheckBox()
• Html.DropDownList()
• Html.EndForm()
• Html.Hidden()
• Html.ListBox()
• Html.Password()
• Html.RadioButton()
• Html.TextArea()
• Html.TextBox()


For example, consider the form in Listing 1. This form is rendered with the help of two of
the standard HTML Helpers (see Figure 1). This form uses the Html.BeginForm() and
Html.TextBox() Helper methods to render a simple HTML form.



Listing 1 – Views\Home\Index.aspx:

<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="Index.aspx.cs"
Inherits="MvcApplication1.Views.Home.Index" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Index</title>
</head>
<body>
<div>
<% using (Html.BeginForm())
{ %>
<label for="firstName">First Name:</label>
<br />
<%= Html.TextBox("firstName")%>...............





     Click here for  Download PDF / FREE




0 commentaires: