asp.net¼òµ¥Êý×ÖÑéÖ¤ÂëµÄʵÏÖ
µ÷ÓÃ
ÑéÖ¤Â룺<input type="text" id="txtValidate" style="border: solid 1px #9B9B9B; width: 85px;
height: 17px;" /> <img src="Rnd.aspx" mce_src="Rnd.aspx" style="width: 58px; height: 17px;
border: solid 1px #9B9B9B" align="absmiddle" />
ºǫ́ʵÏÖ
Rnd.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Drawing;
using System.Drawing.Imaging;
public partial class Rnd : System.Web.UI.Page
{
private int codeLen = 5;//Ëæ»úÏÔʾ×Ö·û¸öÊý
private int fineness = 100;//ͼƬÇåÎú¶È
private int imgWidth = 65;//ͼƬ¿í¶È
private int imgHeight = 20;//ͼƬ¸ß¶È
private string fontFamily = "Roman";//×ÖÌåÃû³Æ
private int fontSize = 12; //×ÖÌå´óС
private Random random = new Random();
protected void Page_Load(object sender, EventArgs e)
{
string validateCode = CreateValidateCode();
Session["RandomNumber"] = validateCode;
Bitmap bitmap = new Bitmap(imgWidth, imgHeight);
DisturbBitmap(bitmap);
DrawValidateCode(bitmap, validateCode);
bitmap.Save(Response.OutputStream, ImageFormat.Gif);
}
private string CreateValidateCode()//µÃµ½Ëæ»úÊý
{
string validateCode = "";
for (int i = 0; i < codeLen; i++)
{
int n = random.Next(10);//·µ»ØÒ»¸öСÓÚ×î´óÖµµÃËæ»úÊý
validateCode += n.ToString();
}
return validateCode;
}
private void DisturbBitmap(Bitmap bitmap)//»ñÈ¡±³¾°Í¼
{
for (int i = 0; i < bitmap.Width; i++)
{
for (int j = 0; j < bitmap.Height; j++)
{
if (random.Next(90) <= this.fineness)
{
Ïà¹ØÎĵµ£º
asp.net´°ÌåµÄ´ò¿ªºÍ¹Ø±Õ
//´ò¿ªÐµĴ°Ìå
Response.Redirect("WebMain.aspx");
//µ¯³öÒ»¸öд°Ìå
Response.Write("<script>window.open(\"WebMain.aspx\")</script>")
//µ¯³öÒ»¸öÖ»ÓÐÈ·¶¨°´Å¥µÄÌáʾ¿ò
Response.Write("<script>alert(\"Óû§Ãû»òÃÜÂë´íÎó\");</script>") ......
Ö±½ÓÖØÐ´Renderʼþ
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
StringWriter sw = new StringWriter() ;
&nb ......
protected void Button6_Click(object sender, EventArgs e)
{
this.Label11.Text = HtmlEncode(this.TextBox3.Text);
}
protected static string HtmlEn ......
1. Êý¾Ý¿â·ÃÎÊÐÔÄÜÓÅ»¯¡¡
¡¡
Êý¾Ý¿âµÄÁ¬½ÓºÍ¹Ø±Õ
·ÃÎÊÊý¾Ý¿â×ÊÔ´ÐèÒª´´½¨Á¬½Ó¡¢´ò¿ªÁ¬½ÓºÍ¹Ø±ÕÁ¬½Ó¼¸¸ö²Ù×÷¡£ÕâЩ¹ý³ÌÐèÒª¶à´ÎÓëÊý¾Ý¿â½»»»ÐÅÏ¢ÒÔͨ¹ýÉí·ÝÑéÖ¤£¬±È½ÏºÄ·Ñ·þÎñÆ÷×ÊÔ´¡£ASP.NETÖÐÌṩÁËÁ¬½Ó³Ø(Connection Pool)¸ÄÉÆ´ò¿ªºÍ¹Ø±ÕÊý¾Ý¿â¶ÔÐÔÄܵÄÓ°Ï졣ϵͳ½«Óû§µÄÊý¾Ý¿âÁ¬½Ó·ÅÔÚÁ¬½Ó³ØÖУ¬ÐèҪʱȡ³ö£¬¹Ø±ÕÊ±Ê ......
public static bool AddTbmember(Tbmember member, string regip)
{
bool check = false;
try
{
SqlCommand sqlcommnad = new SqlCommand("Pro_AddUsers", sqlconn.GetConn());
sqlcommnad.CommandType = CommandType.StoredProcedure; ......