Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ASP.NetÉú³ÉÑéÖ¤Âë

using System;
using System.Web;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
public partial class images_code : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string chkCode = string.Empty;
//ÑÕÉ«ÁÐ±í£¬ÓÃÓÚÑéÖ¤Âë¡¢ÔëÏß¡¢Ôëµã
Color[] color ={ Color.Black, Color.Red, Color.Blue, Color.Green, Color.Orange,Color.Brown, Color.DarkBlue };
//×ÖÌåÁÐ±í£¬ÓÃÓÚÑéÖ¤Âë
string[] font ={ "Times New Roman", "MS Mincho", "Book Antiqua", "Gungsuh","PMingLiU", "Impact" };
//ÑéÖ¤ÂëµÄ×Ö·û¼¯£¬È¥µôÁËһЩÈÝÒ×»ìÏýµÄ×Ö·û
char[] character ={ '2', '3', '4', '5', '6', '8', '9', 'A', 'B', 'C', 'D', 'E','F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'W', 'X', 'Y' };
Random rnd = new Random();
//Éú³ÉÑéÖ¤Âë×Ö·û´®
for (int i = 0; i < 4; i++)
{
chkCode += character[rnd.Next(character.Length)];
}
//±£´æÑéÖ¤ÂëµÄCookie
HttpCookie anycookie = new HttpCookie("validateCookie");
anycookie.Values.Add("ChkCode", chkCode);
HttpContext.Current.Response.Cookies["validateCookie"].Values["ChkCode"] = chkCode;
Bitmap bmp = new Bitmap(80,20);
Graphics g = Graphics.fromImage(bmp);
g.Clear(Color.White);
//»­ÔëÏß
for (int i = 0; i < 3; i++)
{
int x1 = rnd.Next(80);
int y1 = rnd.Next(20);
int x2 = rnd.Next(80);
int y2 = rnd.Next(20);
Color clr = color[rnd.Next(color.Length)];
g.DrawLine(new Pen(clr), x1, y1, x2, y2);
}
//»­ÑéÖ¤Âë×Ö·û´®
for (int i = 0; i < chkCode.Length; i++)
{
string fnt = font[rnd.Next(font.Length)];
Font ft = new Font(fnt, 11);
Color clr = color[rnd.Next(color.Length)];
g.DrawString(chkCode.ToString(), ft, new SolidBrush(clr), (float)i * 20 + 6, (float)2);
}
//»­Ôëµã
for (int i = 0; i < 50; i++)
{
int x = rnd.Next(bmp.Width);
int y = rnd.Next(bmp.Height);
Color clr = color[rnd.Next(color.Length)];
bmp.SetPixel(x, y, clr);
}
//Çå³ý¸ÃÒ³Êä³ö»º´æ£¬ÉèÖøÃÒ³ÎÞ»º´æ
Response.Buffer = true;
Response.ExpiresAbsolute = System.DateTime.Now.AddMilliseconds(0);
Response.Expires = 0


Ïà¹ØÎĵµ£º

Asp.NET³£Óú¯Êý

Ucase(string) ½«×Ö·û´®×ª»»Îª´óд¡£
Val(string) ½«´ú±íÊý×ÖµÄ×Ö·û´®×ª»»ÎªÊýÖµÐÍ̬£¬Èô×Ö·û´®Öк¬ÓзÇÊý×ÖµÄÄÚÈÝÔò»á½«ÆäÈ¥³ýºó£¬ºÏ²¢ÎªÒ»Êý×Ö¡£
Weekday(date) È¡µÄ²ÎÊýÖеÄÈÕÆÚÊÇÒ»¸öÐÇÆÚµÄµÚ¼¸Ì죬ÐÇÆÚÌìΪ1¡¢ÐÇÆÚһΪ2¡¢ÐÇÆÚ¶þΪ3 ÒÀ´ËÀàÍÆ¡£
WeekDayName(number) ÒÀ½ÓÊյIJÎÊýÈ¡µÃÐÇÆÚµÄÃû³Æ£¬¿É½ÓÊյIJÎÊýΪ1 µ½ ......

asp.net½«Ò³ÃæÖÐgridviewÖеÄÊý¾Ýµ¼Èëexcel±íÖÐ

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
namespace ......

Asp.netÊý¾Ý°ó¶¨

Êý¾Ý°ó¶¨ÒÔ¼°Container.DataItemµÄ¾ßÌå·ÖÎö
Áé»îµÄÔËÓÃÊý¾Ý°ó¶¨²Ù×÷
°ó¶¨µ½¼òµ¥ÊôÐÔ:<%#UserName%>
°ó¶¨µ½¼¯ºÏ:<asp:ListBox id="ListBox1" datasource='<%# myArray%>' runat="server">
°ó¶¨µ½±í´ïʽ:<%#(class1.property1.ToString() + "," + class1.property2.ToString())%>
°ó¶¨µ½·½·¨·µ» ......

ASP.NET + CSSʵÏÖ¶¯Ì¬²Ëµ¥Í»³öÏÔʾµ±Ç°Ò³Ãæ

ÍøÉϹØÓÚÍ»³öÏÔʾµ±Ç°Ò³ÃæµÄÎÄÕÂÓв»ÉÙ£¬µ«ÊÇ»ù±¾¶¼ÊǹØÓÚʵÏÖ¾²Ì¬²Ëµ¥µÄ¸ßÁÁ£¬½²µ½¶¯Ì¬Éú³É²Ëµ¥¸ßÁÁµÄÎÄÕÂÖÁÉÙÎÒûÓÐÕÒµ½£¬ÔÚcsdnÉÏÎÊÁËÁ½Ì춼ûÓд𰸣¬×îºóÔÚһλÅóÓѵĻشðÖÐÕÒµ½Ë¼Â·£¬ÏÈÀûÓÃÒ»¸öº¯ÊýÅжϲ˵¥ÊÇ·ñÊÇÕýÔÚä¯ÀÀµÄµ±Ç°Ò³£¬È»ºó¸¶¸øliÒ»¸öid£¬ÀûÓÃcss²ãµþid´óÓÚclassµÄ¹ØÏµ£¬°ÑÕâ¸öid¶¨Òå³É¸ßÁÁÑùʽ¡£
aspx ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ