Partition Web Apps Intelligently: C#: Create the Edit Contacts View: Listing 2

The code for the edit contacts view is simple and straightforward.

<%@ Page Title="" Language="C#" 
    MasterPageFile="~/Views/Shared/Site.Master" 
    AutoEventWireup="true" 
    CodeBehind="Create.aspx.cs" 
    Inherits="Pim.Web.Views.Contacts.Edit" %>
<%@ Import Namespace="Pim.Web" %>
<%@ Import Namespace="Pim.Web.Controllers" %>
<%@ Import Namespace="Pim.Mvc.Web.Models.Home" %>

<asp:Content ID="Content2" 
    ContentPlaceHolderID="mainContent" runat="server">

<form id="mainForm" name="mainForm" 
    action="<%=Url.Action("Create") %>" 
    method="post">
    <table><tr><td>
    <table>
    <tr>
        <td>First Name:</td>
        <td>
            <%=Html.TextBox("Contact.FirstName")%>
            <%=Html.ValidationMessage("Contact.
                FirstName") %>
        </td>
    </tr>
    <tr>
        <td>Last Name:</td>
        <td>
            <%=Html.TextBox("Contact.LastName") %>
            <%=Html.ValidationMessage(
                "Contact.LastName")%>
        </td>
    </tr>
    <tr>
        <td>Email:</td>
        <td>
            <%=Html.TextBox("Contact.Email")%>
            <%=Html.ValidationMessage(
                "Contact.Email")%>
        </td>
    </tr>
    <tr>
        <td>Company:</td>
        <td>
            <%=Html.TextBox("Contact.Company")%>
            <%=Html.ValidationMessage(
                "Contact.Company")%>
        </td>
    </tr>
    <tr>
        <td>Title:</td>
        <td>
            <%=Html.TextBox("Contact.Title")%>
            <%=Html.ValidationMessage(
                "Contact.Title")%>
        </td>
    </tr>
    </table>
    </td>
    
    <td valign="top">
    <table>
    <tr>
        <td>Street Address:</td>
        <td>
            <%=Html.TextBox(
                "Contact.Address.StreetAddress")%>
            <%=Html.ValidationMessage(
                "Contact.Address.StreetAddress")%>
        </td>
    </tr>
    <tr>
        <td>City:</td>
        <td>
            <%=Html.TextBox("Contact.Address.City")%>
            <%=Html.ValidationMessage(
                "Contact.Address.City")%>
        </td>
    </tr>
    <tr>
        <td>State:</td>
        <td>
            <%=Html.DropDownList("(Select)", 
                "Contact.Address.StateID", new 
                SelectList(this.ViewData.Model.StateList, 
                "StateID", "StateDesc", 
                ViewData.Model.Contact.Address.StateID)) %>
            <%=Html.ValidationMessage("Contact.Address.
               StateID")%>
        </td>
    </tr>
    <tr>
        <td>Zip:</td>
        <td>
            <%=Html.TextBox("Contact.Address.Zip")%>
            <%=Html.ValidationMessage("Contact.Address.Zip")%>
        </td>
    </tr>
    </table>
    </td>
</tr></table>
   

    <a href="javascript:document.mainForm.
       submit();">Save</a>

    <%=Html.ActionLink<ContactsController>(c 
        => c.Index(), "Cancel") %>
    
    <%=Html.Hidden("Contact.ContactID") %>
    <%=Html.Hidden("Contact.LastUpdated", 
        ViewData.Model.Contact.LastUpdated.ToString(
        "MM/dd/yyyy HH:mm:ss.fff"))%>
    
</form>
</asp:Content>   
  
comments powered by Disqus
Most   Popular
Upcoming Events

.NET Insight

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.