所罗门蜘蛛用喝水?:手机选号器

来源:百度文库 编辑:高校问答 时间:2024/04/28 19:27:30
看到好多娱乐节目都有一个环节是幸运抽奖,就是从发送短信的观众中选择一定数量的幸运观众。不知道那个手机选号的程序哪里有,希望知道的人给些提示。谢谢。

我写的:
default.aspx.cs的代码:
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 Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
char code;
int number;
string checkCode = String.Empty;
Random r = new Random();
for(int i=0;i<8;i++)
{
number = r.Next();
code = (char)('0' + (char)(number % 10));
checkCode += code.ToString();
}
this.TextBox2.Text = this.TextBox1.Text + checkCode;
}
}
default.aspx的代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!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>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server" Width="126px">请输入前三号码</asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" Width="147px">随即号码</asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>
</form>
</body>
</html>