¡¡¡¡×Ô´ÓÉÏ´ÎÓÐÁËÒ»´ÎÆƽâÑéÖ¤ÂëµÄ¾Ñéºó£¬¾ÍÒ»Ö±Ïë×Ô¼ºÐ´¸öÏñÑùµãµÄÑéÖ¤Âë¡£½ñÌìÎÞÁÄËùÒÔ¾ÍдÁË£¬×ÜÌåÉÏÀ´Ëµ»¹ËãºÜÂúÒâ¡£¾ÍÊÇÓÐʱ¸´ÔÓµÃÈâÑÛ¶¼¿´²»³öÊÇɶ£¨ÕâÒ²¸úͼƬ̫СÓйØϵ£©¡£
¡¡¡¡Õâ¸öÑéÖ¤ÂëÖ§³ÖËæ»ú×ÖÌå¡¢×ÖÌå´óС¡¢×ÖÌåÑùʽ£¨ÆÕͨ¡¢´ÖÌ塢бÌ壩¡¢×ÖÌåÑÕÉ«¡¢×Ô¶¨Òå×Ö·ûµÈ¡£
¡¡¡¡´úÂëÖеÄlibFontÊÇ×ÖÌå¿â£¬libCharÊÇ×Ö·û¿â£¬libColorÊÇÑÕÉ«¿â£¬¿ÉÒÔ×Ô¼ºÀ©³ä¡£
¡¡¡¡Á½¸öwhileÑ»·£¬µÚÒ»¸öÊÇ»¸ÉÈÅÏߵģ¬µÚ¶þ¸öÊÇ»×Ö·ûµÄ£¬ÏߺÍ×Ö·ûµÄ¶àºÍÉÙ¿ÉÒÔ×Ô¼º¿ØÖÆ¡£
¡¡¡¡×îºóÊÇSession["SAFECODE"]£¬×Ô¼ºÒ²¿ÉÒÔÐ޸ģ¬Ä¬ÈÏÊÇ°ÑËùÓÐ×Ö·û¶¼×ª³É´óдµÄ¡£
¡¡¡¡ÆäËüµÄ¾ÍûʲôºÃ˵µÄÁË£¬¿´´úÂë°É¡£
<%@ Page Language="C#" %>
<%@ import Namespace="System.IO" %>
<%@ import Namespace="System.Web" %>
<%@ import Namespace="System.Drawing" %>
<mce:script runat="server"><!--
// Ñùʽ¿â ¸ñʽ: Name|Size(em)|Style
private static string[] libFont = new string[]
{
"ËÎÌå|12|Bold", "ËÎÌå|12|Italic", "ËÎÌå|12|Regular",
"Arial|12|Bold", "Arial|12|Italic", "Arial|12|Regular",
"Tahoma|12|Bold", "Tahoma|12|Italic", "Tahoma|12|Regular",
"Verdana|12|Bold", "Verdana|12|Italic", "Verdana|12|Regular"
};
// ×Ö·û¿â
private static string[] libChar = new string[]
{
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"
};
// ÑÕÉ«¿â
private static string[] libColor = new string[]
{
"Blue", "Red", "Green", "DarkGreen", "DarkBlue", "Tomato"
};
private void Page_Load(object sender, System.EventArgs e)
{
GetSafeCode();
}
private void GetSafeCode()
{
Random r = null;
Bitmap bmp = null;
Graphics g = null;
MemoryStream stream = null;
string[]
asp.netÖеÄhtml¿Ø¼þrunat=serverʱµÄÓ³Éä 1¡¢±ê×¼xhtml±êÇ©£ºhttp://blog.csdn.net/TangZhongxin/archive/2009/07/31/4398487.aspx 2¡¢¾ø´ó¶àÊý±êÇ©¶¼Ó³Éäµ½¡°System.Web.UI.HtmlControls.HtmlGenericControl¡±£¬ËüÃǵĹ²Í¬ÌØÐÔÊÇ¡°ÐÅÏ¢Ö»¶Á£¬½ö¹©ÏÔʾµÄ±ê¼Ç¡±£º
div,span,p,h1,h2,h3,h4,h5,h6,ul,li,dl,dt,dd, ......
¸ÅÄÆäʵ˼··Ç³£¼òµ¥£¬¾ÍÏñ»»Ò»Ñù£¬ÄãÄÔÖеıýͼÏëɶÑù×ӵģ¬¾Í°ÑËüÔÚÍøÒ³ÀﻳöÀ´¶øÒÑ¡£ÏàÐÅ´ó¼ÒСʱºò¶¼»¹ý»£¬²»Í¬µÄÊÇ£¬Ð¡Ê±ºò£¬ÔÚÖ½ÉÏ»£¬ÏÖÔÚÔÚÍøÒ³ÉÏ»¡£
ÕâÊÇÎÒÄÔ×ÓÀï±ýͼµÄÑù×Ó£º<¼¤¹â´«Õæ»ú>
C#ºǫ́ʾÀý´úÂ룺<¼¤¹âÒ»Ìå»ú>
using System;
using System.Data;
using System.Configur ......