⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 orderform.aspx

📁 asp.net技术内幕的书配源码
💻 ASPX
字号:
<%@ Page Language="C#"%>
<%@ Import Namespace="myComponents" %>

<script runat=server>

void Button_Click(object s, EventArgs e) 
{
  BizObject  myBizObject = new BizObject();
  if (IsValid)
  {
	try 
	{
		myBizObject.CheckOrder(txtCustomer.Text, dropProduct.SelectedItem.Text, Convert.ToDouble(txtUnitPrice.Text), Convert.ToInt32(txtQuantity.Text), dropState.SelectedItem.Text );
	}
	catch (Exception expException)
	{
		lblError.Text = expException.Message;
	}
  }
}

</Script>

<html>
<head><title>OrderForm.aspx</title></head>
<body>

<form Runat="Server">

<h2>Enter an Order:</h2>

<asp:Label
  id="lblError"
  ForeColor="Red"
  Font-Bold="True"
  EnableViewState="False"
  Runat="Server" />

<p>
Customer Name:
<br>
<asp:TextBox
  id="txtCustomer"
  Runat="Server" />

<asp:RequiredFieldValidator
  ControlToValidate="txtCustomer"
  Text="You must enter a customer name!"
  Runat="Server" />

<p>
Product:
<br>
<asp:ListBox
  id="dropProduct"
  Runat="Server">
  <asp:ListItem Text="Hair Dryer" />
  <asp:ListItem Text="Shaving Cream" />
  <asp:ListItem Text="Electric Comb" />
</asp:ListBox>

<asp:RequiredFieldValidator
  ControlToValidate="dropProduct"
  Text="You must select a product!"
  Runat="Server" />

<p>
Unit Price:
<br>
<asp:TextBox
  id="txtUnitPrice"
  Runat="Server" />

<asp:RequiredFieldValidator
  ControlToValidate="txtUnitPrice"
  Text="You must enter a unit price!"
  Runat="Server" />


<p>
Quantity:
<br>
<asp:TextBox
  id="txtQuantity"
  Runat="Server" />

<asp:RequiredFieldValidator
  ControlToValidate="txtQuantity"
  Text="You must enter a quantity!"
  Runat="Server" />

<asp:CompareValidator
  ControlToValidate="txtQuantity"
  Text="Quantity must be a number!"
  Operator="DataTypeCheck"
  Type="Integer"
  Runat="Server" />

<p>
Customer State:
<br>
<asp:DropDownList
  id="dropState"
  Runat="Server">
  <asp:ListItem Text="California" />
  <asp:ListItem Text="Nevada" />
  <asp:ListItem Text="Washington" />
</asp:DropDownList>

<p>
<asp:Button
  Text="Place Order"
  OnClick="Button_Click"
  Runat="Server" />

</form>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -