为什么输入localhost:8080不能进入下面这个页面,输入localhost:9090才能进入下面这个页面
用JS怎么实现点击按钮,能相当于网页的后退功能
直接再按钮上添加点击事件; 如返回按钮
《a href=“javascript:history.back(-1);“》返回上一页《/a》
asp验证码是用什么方法实现的
一般正规写法如下
《td》《img id=“img1“ alt=““ src=“ValidateCode.ashx“ /》《/td》
登录按钮下面进行
if (txtValidateCode.Text!= Session[“ValidateCode“].ToString())
{
Response.Write(“验证码输入错误,请重新输入!“);
}
3. 添加一个一般处理程序ValidateCode.ashx
再写一个ValidateCode.ashx,里面代码如下
public class ValidateCode : IHttpHandler, IRequiresSessionState
{
private static char constant = { ’3’, ’4’, ’5’, ’7’, ’8’, ’9’, ’a’, ’d’, ’e’, ’f’, ’g’, ’h’, ’i’, ’j’, ’k’, ’m’, ’n’, ’p’, ’r’, ’s’, ’t’, ’u’, ’v’, ’w’, ’x’, ’y’, ’A’, ’B’, ’D’, ’E’, ’F’, ’H’, ’J’, ’K’, ’L’, ’M’, ’N’, ’P’, ’Q’, ’R’, ’S’, ’T’, ’U’, ’V’, ’W’, ’X’, ’Y’ };-c
public void ProcessRequest(HttpContext context)
{
//context.Response.ContentType = “text/jpg“;
//context.Response.Write(“Hello World“);
Bitmap newBitmap = new Bitmap(76, 25, System.Drawing.Imaging.PixelFormat.Format32bppArgb);-s
Graphics g = Graphics.FromImage(newBitmap);
Random r = new Random();
g.Clear(Color.White);
System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, 86, 26), Color.Red, Color.Blue, 1.2f, true);-c
for (int i = 0; i 《 25; i++)
{
int x1 = r.Next(newBitmap.Width);
int x2 = r.Next(newBitmap.Width);
int y1 = r.Next(newBitmap.Height);
int y2 = r.Next(newBitmap.Height);
g.DrawLine(new Pen(Color.Silver), x1, y1, x2, y2);
}
for (int i = 0; i 《 100; i++)
{
int x = r.Next(newBitmap.Width);
int y = r.Next(newBitmap.Height);
newBitmap.SetPixel(x, y, Color.FromArgb(r.Next()));
}
string value = GenerateRandom(4);
Font font = new Font(“黑体“, 16, System.Drawing.FontStyle.Bold);
g.DrawString(value, font, brush, 2, 2);
g.DrawRectangle(new Pen(Color.Silver), 0, 0, 85, 25);
//g.FillRectangle(new SolidBrush(Color.Green), 0, 12, 80, 1);
System.IO.MemoryStream ms = new System.IO.MemoryStream();
newBitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
context.Response.ClearContent();
context.Response.ContentType = “image/gif“;
context.Response.BinaryWrite(ms.ToArray());
context.Session[“ValidateCode“] = value;
}
public string GenerateRandom(int Length)
{
System.Text.StringBuilder newRandom = new System.Text.StringBuilder(47);
Random rd = new Random();
for (int i = 0; i 《 Length; i++)
{
newRandom.Append(constant[rd.Next(47)]);
}
return newRandom.ToString();
}
public bool IsReusable
{
get
{
return false;
}
}