HTML and CSS Reference
In-Depth Information
flag = true;
return Json(flag);
The IsDuplicateEmail() method accepts an e-mail address to be verified and returns true if it already
exists in the database. Similarly, IsDuplicateDisplayName() accepts a display name and returns true if it
already exists. Notice that both of these methods return true or false after wrapping the value as a
JsonResult object.
Displaying the User Registration Form in an MVC View
The User Registration form is rendered using MVC HTML helpers. The Index view that displays the form is
strongly typed with the User class. Listing 5-29 shows the form's markup. Note that to save space, table
markup tags as well as jQuery code have been omitted and are indicated with ellipses.
Listing 5-29. Using HTML Helpers to Render the User Registration Form
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage
<SampleAppMVC.Models.User>" %>
<% using (Html.BeginForm("Index","User","POST")) { %>
<%= Html.LabelFor(model => model.DisplayName)%>
<%= Html.TextBoxFor(model=>model.DisplayName,
new {required="required"})%>
<%= Html.ValidationMessageFor(model=>model.DisplayName,"*")%>
<%= Html.LabelFor(model=>model.Email)%>
<%= Html.TextBoxFor(model=>model.Email,
new {required="required",type="email"})%>
<%= Html.ValidationMessageFor(model=>model.Email,"*")%>
<%= Html.LabelFor(model=>model.Password)%>
<%= Html.PasswordFor(model=>model.Password,new {required="required"})%>
<%= Html.ValidationMessageFor(model=>model.Password,"*")%>
<%= Html.Label("Conirm password")%>
<%= Html.Password("ConirmPassword", "",new {required="required"})%>
<%= Html.ValidationMessage("ConirmPassword","*")%>
<%= Html.LabelFor(model=>model.BlogUrl)%>
<%= Html.TextBoxFor(model=>model.BlogUrl, new {type="url"})%>
<%= Html.ValidationMessageFor(model=>model.BlogUrl,"*")%>
<%= Html.LabelFor(model=>model.Age)%>
Search WWH ::

Custom Search