?? addressform.ascx.cs
字號(hào):
?using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class controls_AddressForm : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
/// <summary>
/// 定義控件的公開(kāi)屬性-地址
/// </summary>
public AddressInfo Address
{
get
{
// 判斷文本內(nèi)容是否為空
if (string.IsNullOrEmpty(txtName.Text) &&
string.IsNullOrEmpty(txtAddress.Text) &&
string.IsNullOrEmpty(txtZip.Text) &&
string.IsNullOrEmpty(txtEmail.Text) &&
string.IsNullOrEmpty(txtPhone.Text))
return null;
// 驗(yàn)證數(shù)據(jù)內(nèi)容
string userName = Product.InputText(txtName.Text, 50);
string address = Product.InputText(txtAddress.Text, 50);
string zip = Product.InputText(txtZip.Text, 10);
string phone = Product.InputText(txtPhone.Text, 10);
string email = Product.InputText(txtEmail.Text, 80);
string country = Product.InputText(listCountry.SelectedItem.Value, 50);
//創(chuàng)建一個(gè)地址類實(shí)體對(duì)象。
return new AddressInfo(userName, address, zip, country, phone, email);
}
set
{
//為實(shí)體類對(duì)象賦值
if (value != null)
{
if (!string.IsNullOrEmpty(value.UserName))
txtName.Text = value.UserName;
if (!string.IsNullOrEmpty(value.Address))
txtAddress.Text = value.Address;
if (!string.IsNullOrEmpty(value.ZipCode))
txtZip.Text = value.ZipCode;
if (!string.IsNullOrEmpty(value.Phone))
txtPhone.Text = value.Phone;
if (!string.IsNullOrEmpty(value.Email))
txtEmail.Text = value.Email;
if (!string.IsNullOrEmpty(value.Country))
{
listCountry.ClearSelection();
listCountry.SelectedValue = value.Country;
}
}
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -