ASP.NETÑéÖ¤Âë(C#)
* Copyright all(c) 2005 ZhongFeng, http://blog.csdn.net/SW515 */
public class ValidateCode : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
this.CreateCheckCodeImage(GenerateCheckCode());
}
#region Web ´°ÌåÉè¼ÆÆ÷Éú³ÉµÄ´úÂë
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: ¸Ãµ÷ÓÃÊÇ ASP.NET Web ´°ÌåÉè¼ÆÆ÷Ëù±ØÐèµÄ¡£
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Éè¼ÆÆ÷Ö§³ÖËùÐèµÄ·½·¨ - ²»ÒªÊ¹ÓôúÂë±à¼Æ÷ÐÞ¸Ä
/// ´Ë·½·¨µÄÄÚÈÝ¡£
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private string GenerateCheckCode()
{
int number;
char code;
string checkCode = String.Empty;
System.Random random = new Random();
for(int i=0; i<5; i++)
{
number = random.Next();
if(number % 2 == 0)
code = (char)('0' + (char)(number % 10));
else
code = (char)('A' + (char)(number % 26));
checkCode += code.ToString();
}
Response.Cookies.Add(new HttpCookie("CheckCode", checkCode));
return checkCode;
}
private void CreateCheckCodeImage(string checkCode)
{
if(checkCode == null || checkCode.Trim() == String.Empty)
return;
System.Drawing.Bitmap
Ïà¹ØÎĵµ£º
À´Ô´£ºhttp://www.ej38.com/showinfo/asp.net-180538.html
1. DotNetNuke(ASP.NET 2.0) ¸öÈËÍƼöÉîÈëÑо¿
DotNetNukeÊÇÒ»¸öWebÓ¦Óÿò¼ÜµÄÀíÏë,Ϊ´´½¨ºÍ²¿ÊðµÄÏîÄ¿,ÈçÉÌÒµÍøÕ¾,ÆóÒµÄÚÁªÍøºÍÍâÁªÍø,ÔÚÍøÉϳö°æÃÅ»§,²¢¶¨ÖÆ´¹Ö±Ó¦ÓÃÈí¼þ¡£ ·½±ãÓû§-DotNetNukeÖ¼ÔÚʹÓû§¿ÉÒÔ¸üÇáËɵعÜÀíËùÓз½ÃæµÄÏîÄ¿¡£
ÏÂÔØÍøÖ·:http:// ......
±¾ÊéÊÇ΢Èí¼¼ÊõÅàѵͳ±à½Ì²ÄÖ®Ò»£¬¶Ô±à³ÌÓïÑÔC#½øÐÐÁËÏêϸµÄ½éÉÜ¡£ C#ÊÇ»ùÓÚ΢ÈíÏÂÒ»´ú²Ù×÷ƽ̨£®NETµÄȫеÄÃæÏò¶ÔÏóµÄ³ÌÐòÉè¼ÆÓïÑÔ¡£ËüÔÚ±£³ÖÁËC+ÖÐÊìϤµÄÓï·¨µÄͬʱ£¬Ìí¼ÓÁË´óÁ¿µÄ¸ßЧ´úÂëºÍÍêÈ«ÃæÏò¶ÔÏóÌØÐÔ£¬ÒÔ¼°¸ü¸ßµÄ¿É¿¿ÐԺͰ²È«ÐÔ¡£C#ÓïÑÔ½«ÔÚ±£³ÖC£¯C++Áé»îÐԵĻù´¡ÉÏΪ³ÌÐòÔ±´øÀ´¸ü¸ßЧµÄ¿ª·¢·½Ê½¡£Ëü²»½öÄÜÓÃÓ ......
ÕâÊǹØÓÚAsp.Net/XMLÉîÈë±à³ÌµÄ¼¼ÊõÊ飬×÷Õß¾«ÐÄÉè¼ÆÁË66¸öʵÀýÏêϸ½éÉÜÁË.Net FrameworkÒÔ¼°XML¼¼ÊõÔÚ.Net FrameworkµÄ±à³Ì·½·¨ºÍ¼¼ÇÉ¡£È«ÊéÓÉ12Õ¹¹³É£¬ÄÚÈÝ°üÀ¨.Netƽ̨µÄ½¨Á¢¡¢Asp.NetµÄWeb Forms¡¢¿Ø¼þ¡¢Êý¾Ý·ÃÎÊ¡¢Web Service¡¢Asp.NetµÄÉèÖú͸ú×Ù¡¢Asp.NetµÄ°²È« ......
1.Á¬½ÓÊý¾Ý¿âÎļþ
<add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;AttachDBFilename=|DataDirectory|TimeTracker.mdf;User Instance=true" />
SqlConnectionStringBuilderʵÀý»¯Ê±£¬ÒªÓõ½connectionString£¬È磺SqlConnectionStringBuild builder = new SqlCon ......
×Ö·û´®µÄ¿í¶È×ÔÊÊÓ¦ÈÝÆ÷
Graphics g = Graphics.fromImage(new Bitmap(1, 1));
SizeF size = g.MeasureString(lblTitle.Text, new Font("ËÎÌå", 24 * 0.0625F, FontStyle.Bold));
float oldSize=(800*0.0625F);//1px=0.0625em
float newSize = (0.75F/size.Width )* oldSize;
size.Width µÄµ¥ ......