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())
{
&
Ïà¹ØÎĵµ£º
µÚÒ»£º
private void Button1_Click( object sender, System.EventArgs e ) { Response.Redirect( Request.Url.ToString( ) ); } µÚ¶þ£º
private void Button2_Click( object sender, System.EventArgs e ) { Response.Write( " < script language=javascript>window.location.href=document.URL; < /sc ......
´Ë´¦ÌṩµÄ´úÂëÓÃÀ´ÊµÏÖµ±asp.netÒ³ÃæÖеÄij¸öButton±»µã»÷ºódisableµô¸ÃÒ³ÃæÖÐËùÓеÄButton£¬´Ó¶ø·ÀÖ¹Ìá½»ÑÓʱµ¼ÖµĶà´ÎÌá½»¡£»ùÓÚ֮ǰµÄonceclickbutton½Å±¾.
//ASP.NETÖзÀÖ¹Ò³Ãæ¶à´ÎÌá½»µÄ´úÂë:javascript< script language="javascript"> < !-- function disableOtherSubmit() {
var ......
CheckBoxÑ¡Ôñ×é¼þÊÇÒ»¸ö³ÌÐòÖж¼¾³£µÄ×é¼þ¡£ÔÚ³ÌÐòÉè¼ÆÖÐʹÓõ½¸Ã×é¼þ£¬Ò»°ã¶¼²»»áֻʹÓõ½Ò»¸ö£¬ÍùÍùÊÇÒÔ¶à¸ö´ËÀà×é¼þµÄÐÎʽ³öÏֵġ£ÔÚASP.NETÒ³ÃæÖÐÈç¹ûҪʹÓõ½¶à¸öCheckBox×é¼þ£¬³ýÁËÌí¼Ó¶à¸öCheckBox×é¼þÔÚÒ³ÃæÖÐÖ®Í⣬»¹ÓÐÒ»ÖֱȽϷ½±ãµÄ·½·¨£¬¾ÍÊÇʹÓÃCheckBoxList ×é¼þ¡£CheckBoxList×é¼þÊÇÓÉÒ»×éµÄCheckBox×é¼þ×é ......
1. ¼òÊö private¡¢ protected¡¢ public¡¢ internal ÐÞÊηûµÄ·ÃÎÊȨÏÞ¡£
´ð . private : ˽ÓгÉÔ±, ÔÚÀàµÄÄÚ²¿²Å¿ÉÒÔ·ÃÎÊ¡£
protected : ±£»¤³ÉÔ±£¬¸ÃÀàÄÚ²¿ºÍ¼Ì³ÐÀàÖпÉÒÔ·ÃÎÊ¡£
public : ¹«¹²³ÉÔ±£¬ÍêÈ«¹«¿ª£¬Ã»ÓзÃÎÊÏÞÖÆ¡£
internal: ÔÚͬһÃüÃû¿Õ¼äÄÚ¿ÉÒÔ·ÃÎÊ¡£
2 .ÁоÙASP.NET Ò³ÃæÖ®¼ä´«µÝÖµµÄ¼¸ÖÖ·½Ê½ ......
CheckBox ¿Ø¼þºÍ CheckBoxList ¿Ø¼þΪÓû§ÌṩÁËÒ»ÖÖÖ¸¶¨ÊÇ/·ñ£¨Õæ/¼Ù£©Ñ¡ÔñµÄ·½·¨¡£
Ò»¡¢¹¦ÄÜ
¿ÉÒÔʹÓà CheckBox ¿Ø¼þºÍ CheckBoxList ¿Ø¼þÖ´ÐÐÒÔϲÙ×÷£º
·µ±Ñ¡ÖÐij¸ö¸´Ñ¡¿òʱ½«ÒýÆðÒ³»Ø·¢¡£
·µ±Óû§Ñ¡ÖÐij¸ö¸´Ñ¡¿òʱ²¶»ñÓû§½»»¥¡£
·½«Ã¿¸ö¸´Ñ¡¿ò°ó¶ ......