1、正则表达式:验证数据格式的准确性。
用正则表达式判断手机号格式是否正确:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;public partial class _Default : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { }}
2、用加减按钮增加减少数量
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;public partial class Default2 : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { Button1.Click += Button1_Click; } void Button1_Click(object sender, EventArgs e) { Label1.Text = TextBox1.Text; }}
3、用checkbox实现全选
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;public partial class Default3 : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { Repeater1.DataSource = new user1data().selectall(); Repeater1.DataBind(); } Button1.Click += Button1_Click; } void Button1_Click(object sender, EventArgs e) { Label1.Text = Request["ck"]; }}
using System;using System.Collections.Generic;using System.Linq;using System.Web;////// user1data 的摘要说明/// public class user1data{ DataClassesDataContext con = new DataClassesDataContext(); public user1data() { } public Listselectall() { return con.user1.ToList(); }}