//产生随机验证码
public static String getYangZhengMa()
{
String tempRsult = "";
Random myRandom = new Random();
for (int i = 0; i < 2; i++)
{
int myGetInt = myRandom.Next(65, 90);
tempRsult += ((char)myGetInt).ToString();
}
return tempRsult;
}
<input type="hidden" runat="server" id="hid_YanZhengMa" />
if (!Page.IsPostBack)
{
this.hid_YanZhengMa.Value = System.mySQLConnection.AllText.getYangZhengMa();
Session["YanZhengMa"] = this.hid_YanZhengMa.Value;
}
protected void submit_jiaoFei_ServerClick(object sender, EventArgs e)
{
if (hid_YanZhengMa.Value.Trim() != ((String)Session["YanZhengMa"]))
{
MessageBox.alert(Page, "不能重复提交");
return;
}
}