Update of /cvsroot/springnet/Spring.Net/examples/Spring/Spring.WebQuickStart/src/Spring.WebQuickStart.2005/DataBinding/EasyEmployeeInfo
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv23425/examples/Spring/Spring.WebQuickStart/src/Spring.WebQuickStart.2005/DataBinding/EasyEmployeeInfo
Added Files:
Default.aspx Default.aspx.cs Web.Config
Log Message:
nant build script's variable ${nowarn.numbers.test} renamed to ${nowarn.numbers.test.default}
DataBindingPanel -> added design-time support (SPRNET-774)
DataBindingPanel -> added examples to SpringWebQuickstart "EasyEmplyeeInfo" (SPRNET-787)
integrated NUnitAspEx (SPRNET-788)
added PageHandlerFactory tests w.r.t. Server.Transfer() (SPRNET-763)
--- NEW FILE: Web.Config ---
<?xml version="1.0"?>
<configuration>
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net">
<!-- define the currencyFormatter used for formatting the salary -->
<object name="theCurrencyFormatter" type="Spring.Globalization.Formatters.CurrencyFormatter" />
</objects>
</spring>
</configuration>
--- NEW FILE: Default.aspx.cs ---
using System;
using System.Diagnostics;
/// <summary>
/// Notice that your web page has to extend Spring.Web.UI.Page class
/// in order to enable data binding and many other features.
/// </summary>
public partial class DataBinding_EasyEmployeeInfo_Default : Spring.Web.UI.Page
{
private EmployeeInfo employee = new EmployeeInfo();
public EmployeeInfo Employee
{
get { return employee; }
}
protected void Page_Load(object sender, EventArgs e)
{}
protected void btnSave_Click(object sender, EventArgs e)
{
// do something with employee such as:
// employeeDao.Save(Employee);
Debug.Write(Employee);
}
}
--- NEW FILE: Default.aspx ---
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="DataBinding_EasyEmployeeInfo_Default" %>
<%@ Register TagPrefix="spring" Namespace="Spring.Web.UI.Controls" Assembly="Spring.Web" %>
<!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>Data Binding - Easy Employee Info example</title>
</head>
<body>
<h2><a href="../../Default.aspx">Welcome to Spring.NET Web Framework Quick Start Guide</a></h2>
<h2><a href="../Default.aspx">Bi-directional DataBinding</a></h2>
<form id="form1" runat="server">
<div>
<h2>Easy Employee Info example</h2>
<p>
Now that you have an idea of how databinding works, here's the easy way using a DataBindingPanel.
</p>
<p>
TODO: describe DataBindingPanel
</p>
<spring:DataBindingPanel ID="ctlDataBindingPanel" runat="server">
<table cellpadding="3" cellspacing="3" border="0">
<tr>
<td>Employee ID:</td>
<td>
<asp:TextBox ID="txtId" runat="server" BindingTarget="Employee.Id" />
<spring:ValidationError ID="ctlIdErrors" Provider="id.errors" runat="server" />
</td>
</tr>
<tr>
<td>First Name:</td>
<td><asp:TextBox ID="txtFirstName" runat="server" BindingTarget="Employee.FirstName" /></td>
</tr>
<tr>
<td>Last Name:</td>
<td><asp:TextBox ID="txtLastName" runat="server" BindingTarget="Employee.LastName" /></td>
</tr>
<tr>
<td>Date of Birth:</td>
<td>
<asp:TextBox ID="txtDOB" runat="server" BindingTarget="Employee.DateOfBirth"/>
<spring:ValidationError ID="ctlDOBErrors" Provider="dob.errors" runat="server" />
</td>
</tr>
<tr>
<td>Gender:</td>
<td>
<!--
RadioButtonGroup control exposes Value property which is set
to the value of the ID property of the selected radio button
-->
<spring:RadioButtonGroup ID="rbgGender" runat="server" BindingTarget="Employee.Gender">
<asp:RadioButton ID="Male" Text="Male" runat="server" />
<asp:RadioButton ID="Female" Text="Female" runat="server" />
</spring:RadioButtonGroup>
</td>
</tr>
<tr>
<td>Salary:</td>
<td>
<asp:TextBox ID="txtSalary" runat="server" BindingTarget="Employee.Salary" BindingFormatter="theCurrencyFormatter" />
<spring:ValidationError ID="ctlSalaryErrors" Provider="salary.errors" runat="server" />
</td>
</tr>
<tr>
<td>Address Type:</td>
<td>
<!--
Another way to select one of the predefined values, which is
how enum values should always be entered
-->
<asp:DropDownList ID="ddlAddressType" runat="server" BindingTarget="Employee.MailingAddress.AddressType">
<asp:ListItem Value="Home" Text="Home" Selected="True" />
<asp:ListItem Value="Office" Text="Office" />
</asp:DropDownList>
</td>
</tr>
<tr>
<td>Street 1:</td>
<td><asp:TextBox ID="txtStreet1" runat="server" BindingTarget="Employee.MailingAddress.Street1" /></td>
</tr>
<tr>
<td>Street 2:</td>
<td><asp:TextBox ID="txtStreet2" runat="server" BindingTarget="Employee.MailingAddress.Street2" /></td>
</tr>
<tr>
<td>City:</td>
<td><asp:TextBox ID="txtCity" runat="server" BindingTarget="Employee.MailingAddress.City" /></td>
</tr>
<tr>
<td>State:</td>
<td><asp:TextBox ID="txtState" runat="server" BindingTarget="Employee.MailingAddress.State" /></td>
</tr>
<tr>
<td>Postal Code/ZIP:</td>
<td><asp:TextBox ID="txtPostalCode" runat="server" BindingTarget="Employee.MailingAddress.PostalCode" /></td>
</tr>
<tr>
<td>Country:</td>
<td><asp:TextBox ID="txtCountry" runat="server" BindingTarget="Employee.MailingAddress.Country" /></td>
</tr>
<tr>
<td> </td>
<td><asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" /></td>
</tr>
</table>
</spring:DataBindingPanel>
</div>
</form>
</body>
</html>
|