ASP.NETÖÐʹÓÃÑéÖ¤Âë¼¼Êõ
ÓÉÓÚÑéÖ¤Âë¼¼ÊõÖзþÎñÆ÷³ÌÐòÐèÒª´´½¨ÑéÖ¤ÂëͼƬ£¬ÀïÃæÓõ½ÁËͼÐαà³Ì£¬Òò´Ë±¾½Ú¿Î³ÌÈÔÈ»ÊÇC#·¢ÏÖÖ®ÂõÄͼÐαà³ÌϵÁн̡̳£
¸ù¾ÝÑéÖ¤ÂëµÄÔÀí£¬ÎÒÃÇʹÓÃC#ÔÚASP.NETÖÐʵÏÖÁËÑéÖ¤ÂëµÄ¹¦ÄÜ¡£
checkimage.aspx
Ê×Ïȸù¾ÝÉϽڿγ̵ÄÄÚÈÝ£¬ÎÒÃÇÒª´´½¨Ò»¸öͼƬ·þÎñÒ³Ãæ£¬×¨ÃÅÓÃÓÚÌṩ°üº¬ÑéÖ¤ÂëÎı¾µÄͼƬ£¬Îª´ËÎÒÃǽ¨Á¢Ò»¸ö checkimage.aspx µÄÒ³Ãæ¡£ÆäHTML´úÂëºÜ¼òµ¥£¬Ö»ÓÐÒ»ÐУ¬²»Êä³öÈκÎÄÚÈÝ¡£ÔÚÆäPage_Load·½·¨ÖоÍÓд´½¨ÑéÖ¤ÂëͼƬµÄ¹ý³Ì¡£
// ´´½¨Ò»¸ö°üº¬Ëæ»úÄÚÈݵÄÑéÖ¤ÂëÎı¾
System.Random rand = new Random();
int len = rand.Next(4 , 6 );
char[] chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();
System.Text.StringBuilder myStr = new System.Text.StringBuilder();
for( int iCount = 0 ; iCount < len ; iCount ++ )
{
myStr.Append( chars[ rand.Next( chars.Length )]);
}
string text = myStr.ToString();
// ±£´æÑéÖ¤Âëµ½ session ÖÐÒÔ±ãÆäËûÄ£¿éʹÓÃ
this.Session["checkcode"] = text ;
Size ImageSize = Size.Empty ;
Font myFont = new Font("MS Sans Serif" , 20 );
// ¼ÆËãÑéÖ¤ÂëͼƬ´óС
using( Bitmap bmp = new Bitmap( 10 , 10 ))
{
using( Graphics g = Graphics.fromImage( bmp ))
{
SizeF size = g.MeasureString( text , myFont , 10000 );
ImageSize.Width = ( int ) size.Width + 8 ;
ImageSize.Height = ( int ) size.Height + 8 ;
}
}
// ´´½¨ÑéÖ¤ÂëͼƬ
using( Bitmap bmp = new Bitmap( ImageSize.Width , ImageSize.Height ))
{
// »æÖÆÑéÖ¤ÂëÎı¾
using( Graphics g = Graphics.fromImage( bmp ))
{
g.Clear( Color.White );
using( StringFormat f = new StringFormat())
{
&
Ïà¹ØÎĵµ£º
ÒòΪ°²È«ÐÔÎÊÌ⣬IE7½ûÓÃÁËimage¿Ø¼þÒýÓñ¾µØÍ¼Æ¬£¬ÎªÁËÕâ¸öÎÊÌâÓôÃÆÁ˺ü¸Ì죬ÖÕÓÚÕÒµ½Á˽â¾ö·½°¸£¬ºÃ¶«Î÷ÒªÓë´ó¼Ò·ÖÏí£¬´úÂëÈçÏ£º
´Ë¶Î´úÂë·ÅÓÚ<head> ....</head>Ö®¼ä
<style type="text/css">#newPreview {
FILTER: progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)
} ......
public class t3 : System.Web.UI.Page
{
private string str;//×Ö·û
&n ......
Áù¡¢ÈçºÎ£º×Ô¶¨Òå Calendar Web ·þÎñÆ÷¿Ø¼þµÄÍâ¹Û
ÒòΪ Calendar ¿Ø¼þÊÇÒ»¸öÓÉÐí¶à¸ö±ðÔªËØ×é³ÉµÄ¸´Ôӿؼþ£¬ËüΪÄú×Ô¶¨ÒåÆäÍâ¹ÛÌṩÁ˶à¸öÑ¡Ïî¡£
1¡¢¸ü¸Ä Calendar ¿Ø¼þµÄ³£¹æÍâ¹Û
Calendar ¿Ø¼þ½¨Á¢Ò³ÉϵÄÈÕÀúµÄĬÈÏÍâ¹Û£¬µ«ÊÇÄú¿ÉÒÔ¸ü¸ÄÈÕÀúµÄ×ܵÄÍâ¹ ......
Ê®¡¢ÈçºÎ£º¶ÁÈ¡ Calendar Web ·þÎñÆ÷¿Ø¼þÖеÄÑ¡¶¨ÈÕÆÚ
µÚÒ»¸öʾÀýÏÔʾµ±Ç°Ñ¡¶¨µÄÈÕ¡£µÚ¶þ¸öʾÀýÏÔʾËùÓÐÑ¡¶¨µÄÈÕÆÚ£¬¿ÉÒÔÊǵ¥¸öÈÕ¡¢ÖÜ»òÔ¡£
// Example 1
Label1.Text = Calendar1.SelectedDate.ToShortDateString();
// Example 2
String s = "";
foreach(DateTime d in Ca ......
Global.asax Îļþ£¬ÓÐʱºò½Ð×ö ASP.NET Ó¦ÓóÌÐòÎļþ£¬ÌṩÁËÒ»ÖÖÔÚÒ»¸öÖÐÐÄλÖÃÏìÓ¦Ó¦ÓóÌÐò¼¶»òÄ£¿é¼¶Ê¼þµÄ·½·¨¡£Äã¿ÉÒÔʹÓÃÕâ¸öÎļþʵÏÖÓ¦ÓóÌÐò°²È«ÐÔÒÔ¼°ÆäËüһЩÈÎÎñ¡£ÏÂÃæÈÃÎÒÃÇÏêϸ¿´Ò»ÏÂÈçºÎÔÚÓ¦ÓóÌÐò¿ª·¢¹¤×÷ÖÐʹÓÃÕâ¸öÎļþ¡£
¸ÅÊö
Global.asax λÓÚÓ¦ÓóÌÐò¸ùĿ¼Ï¡£ËäÈ» Visual Studio .NET »á×Ô¶¯²åÈëÕâ ......