濮阳杆衣贸易有限公司

主頁 > 知識庫 > asp.net ajax實(shí)現(xiàn)無刷新驗(yàn)證碼

asp.net ajax實(shí)現(xiàn)無刷新驗(yàn)證碼

熱門標(biāo)簽:天津電銷外呼系統(tǒng)違法嗎 溫州外呼系統(tǒng)招商 銀行信貸電話機(jī)器人 上海400客服電話怎么申請 手機(jī)外呼系統(tǒng)什么原理 400電話個人能不能辦理 滄州電銷外呼系統(tǒng)價(jià)格 合肥ai電銷機(jī)器人費(fèi)用 凱立德地鐵站地圖標(biāo)注
1、首先是在后臺驗(yàn)證碼的aspx文件的Page_Load中的事件代碼:
復(fù)制代碼 代碼如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
namespace 學(xué)生在線考試系統(tǒng)
{
public partial class AjaxAutoCode : System.Web.UI.Page
{
//驗(yàn)證數(shù)字
public string authcode = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
#region 第一種產(chǎn)生驗(yàn)證碼的方法
Random random = new Random();
authcode = random.Next(1111, 9999).ToString();
//構(gòu)造圖片
Bitmap image = new Bitmap(authcode.Length * 12, 25);
//創(chuàng)建畫布
Graphics g = Graphics.FromImage(image);
try
{
g.Clear(Color.White);
for (int i = 0; i 25; i++)
{
int x1 = random.Next(image.Width);
int x2 = random.Next(image.Width);
int y1 = random.Next(image.Height);
int y2 = random.Next(image.Height);
//鏈接兩點(diǎn)的線條
g.DrawLine(new Pen(Color.Silver), x1, y1, x2, y2);
}
Font font = new Font("Arial", 12, FontStyle.Bold | FontStyle.Italic);
System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(
new Rectangle(0, 0, image.Width, image.Height), Color.Blue, Color.DarkBlue, 1.2f, true);
g.DrawString(authcode, font, brush, 2, 2);
//畫圖片的前景噪點(diǎn)
for (int i = 0; i 100; i++)
{
int x = random.Next(image.Width);
int y = random.Next(image.Height);
image.SetPixel(x, y, Color.FromArgb(random.Next()));
}
g.DrawRectangle(new Pen(Color.Silver), 0, 0, image.Width - 1, image.Height - 1);
System.IO.MemoryStream ms = new System.IO.MemoryStream();
image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
ms.WriteTo(this.Response.OutputStream);
ms.Close();
this.Response.ContentType = "image/gif";
}
finally
{
image.Dispose();
g.Dispose();
}
#endregion
}
}
}

2、其次在顯示驗(yàn)證碼的頁面定義一個JS函數(shù)
復(fù)制代碼 代碼如下:

function fGetCode()
{
document.getElementById("getcode").src="Default2.aspx?"+Math.random();
}

3.再編輯前臺頁面aspx,下面是前臺頁面的代碼片段
復(fù)制代碼 代碼如下:

label>驗(yàn)證碼/label>
asp:TextBox ID="txt_checkCode" runat="server" Width="178px">/asp:TextBox>
img src="Default2.aspx" alt="看不清楚?" id="getcode"/> a href="javascript:fGetCode()">更換驗(yàn)證碼/a>
您可能感興趣的文章:
  • asp.net 驗(yàn)證碼生成和刷新及驗(yàn)證
  • ASP.net 驗(yàn)證碼實(shí)現(xiàn)代碼(C#)
  • asp.net(C#) 生成隨機(jī)驗(yàn)證碼的代碼
  • Asp.net(C#)實(shí)現(xiàn)驗(yàn)證碼功能代碼
  • asp.net 簡單驗(yàn)證碼驗(yàn)證實(shí)現(xiàn)代碼
  • ASP.NET MVC驗(yàn)證碼功能實(shí)現(xiàn)代碼
  • ASP.NET 實(shí)現(xiàn)驗(yàn)證碼以及刷新驗(yàn)證碼的小例子
  • ASP.NET中的無刷新驗(yàn)證碼的開發(fā)(完整代碼)
  • asp.net 圖片驗(yàn)證碼的HtmlHelper
  • ASP.NET生成驗(yàn)證碼的方法

標(biāo)簽:赤峰 白城 酒泉 溫州 怒江 七臺河 金華 洛陽

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《asp.net ajax實(shí)現(xiàn)無刷新驗(yàn)證碼》,本文關(guān)鍵詞  asp.net,ajax,實(shí)現(xiàn),無,刷新,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《asp.net ajax實(shí)現(xiàn)無刷新驗(yàn)證碼》相關(guān)的同類信息!
  • 本頁收集關(guān)于asp.net ajax實(shí)現(xiàn)無刷新驗(yàn)證碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    曲麻莱县| 香格里拉县| 琼海市| 建平县| 德清县| 调兵山市| 五寨县| 西林县| 山西省| 抚州市| 邻水| 娄烦县| 巫山县| 定州市| 百色市| 渭南市| 苏尼特右旗| 澄迈县| 石嘴山市| 云林县| 山阴县| 四平市| 巴彦淖尔市| 宿迁市| 马公市| 特克斯县| 临邑县| 锦州市| 措美县| 射洪县| 泰来县| 大埔区| 和平县| 静海县| 淳化县| 奉新县| 略阳县| 古交市| 黑山县| 获嘉县| 溆浦县|