asp.net ajax는 새로 고침 확인 코드를 구현하지 않습니다.
Jan 13, 2017 pm 02:23 PM1. 먼저 백그라운드 인증 코드의 aspx 파일의 Page_Load에 있는 이벤트 코드:
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 学生在线考试系统 { public partial class AjaxAutoCode : System.Web.UI.Page { //验证数字 public string authcode = string.Empty; protected void Page_Load(object sender, EventArgs e) { #region 第一种产生验证码的方法 Random random = new Random(); authcode = random.Next(1111, 9999).ToString(); //构造图片 Bitmap image = new Bitmap(authcode.Length * 12, 25); //创建画布 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); //链接两点的线条 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); //画图片的前景噪点 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. 두 번째로 인증 코드를 표시하는 페이지에 JS 함수를 정의합니다.
function fGetCode() { document.getElementById("getcode").src="Default2.aspx?"+Math.random(); }
로그인 후 복사
3. 그런 다음 첫 페이지 aspx를 편집합니다. 다음은 첫 페이지의 코드 스니펫입니다.
<label>验证码</label> <asp:TextBox ID="txt_checkCode" runat="server" Width="178px"></asp:TextBox> <img src="Default2.aspx" alt="看不清楚?" id="getcode"/> <a href="javascript:fGetCode()">更换验证码</a>
로그인 후 복사
asp.net ajax 새로 고침 없음 인증 코드 구현과 관련된 추가 기사를 보려면 다음을 주의하세요. PHP 중국어 웹사이트!
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

인기 기사
R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
2 몇 주 전
By 尊渡假赌尊渡假赌尊渡假赌
Repo : 팀원을 부활시키는 방법
4 몇 주 전
By 尊渡假赌尊渡假赌尊渡假赌
헬로 키티 아일랜드 어드벤처 : 거대한 씨앗을 얻는 방법
3 몇 주 전
By 尊渡假赌尊渡假赌尊渡假赌
스플릿 소설을이기는 데 얼마나 걸립니까?
3 몇 주 전
By DDD
R.E.P.O. 파일 저장 위치 : 어디에 있고 그것을 보호하는 방법은 무엇입니까?
3 몇 주 전
By DDD

인기 기사
R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
2 몇 주 전
By 尊渡假赌尊渡假赌尊渡假赌
Repo : 팀원을 부활시키는 방법
4 몇 주 전
By 尊渡假赌尊渡假赌尊渡假赌
헬로 키티 아일랜드 어드벤처 : 거대한 씨앗을 얻는 방법
3 몇 주 전
By 尊渡假赌尊渡假赌尊渡假赌
스플릿 소설을이기는 데 얼마나 걸립니까?
3 몇 주 전
By DDD
R.E.P.O. 파일 저장 위치 : 어디에 있고 그것을 보호하는 방법은 무엇입니까?
3 몇 주 전
By DDD

뜨거운 기사 태그

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제
Gmail 이메일의 로그인 입구는 어디에 있나요?
7312
9


자바 튜토리얼
1624
14


Cakephp 튜토리얼
1346
46


라라벨 튜토리얼
1259
25


PHP 튜토리얼
1207
29



C 언어 온라인 프로그래밍 웹 사이트 C 언어 컴파일러 공식 웹 사이트 요약
