Fork me on GitHub
Blog
The journal that this archive was targeting has been deleted. Please update your configuration.
« Behavior | Main | ViewModel »
Friday
Oct052012

View

A View (V) is simply a user interface component in charge of presenting the data from a View Model (VM) and collecting user input, translating user interaction and gestures into an application level event and sends it to the Controller (C) in the form of Behavior Events.

<%@ Control 
Language="C#" 
CodeBehind="StudentProfileView.ascx.cs" 
Inherits="StudentProfileView" %>

ID:         <asp:Label runat="server" ID="LabelID"/> 
First Name: <asp:TextBox runat="server" ID="TextBoxFirstName"/>
Last Name:  <asp:TextBox runat="server" ID="TextBoxLastName"/> 
Email:      <asp:TextBox runat="server" ID="TextBoxEmail"/>


// CODE-BEHIND
public partial class StudentProfileView 
{
    public void Bind(StudentViewModel viewModel)
    {
        // data binding
        this.LabelID.Text = viewModel.Id;
        this.TextBoxFirstName.Text = viewModel.FirstName;
        this.TextBoxLastName.Text = viewModel.LastName;
        this.TextBoxEmail.Text = viewModel.Email;

        // render logic
        this.TextBoxFirstName.Enabled = viewModel.IsInEditMode;
        this.TextBoxLastName.Enabled = viewModel.IsInEditMode;
        this.TextBoxEmail.Enabled = viewModel.IsInEditMode;
    }
}

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>