三款asp.net 驗證碼代碼(1/2)

來源:互聯網
上載者:User

<!--
文章提供三種不同風格 asp教程.net 圖形驗證碼代碼。

<%@ page language="c#" contenttype="text/html" responseencoding="gb2312" %>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.111cn.net/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>三款asp.net教程 驗證碼代碼</title>
</head>

<body>
<%
<cc1:authcode id="authcode1" runat="server"
        imagestyle-imgbgcolor="white" imagestyle-imgbordercolor="deeps教程kyblue"     imagestyle-imgnoisecolor="ivory" imagestyle-textcolor1="azure"  
        imagestyle-textcolor2="ghostwhite" />

  實現這種功能的關鍵在於 [designerserializationvisibility(designerserializationvisibility.content)]
以及 typeconverter(typeof(imagestyletypeconver))  這兩個地方。
  [designerserializationvisibility(designerserializationvisibility.content)] 提示屬性更改好產生
imagestyle-imgbgcolor="white" 這種代碼,至於 typeconverter(typeof(imagestyletypeconver)) 
則主要用於類型轉換,具體的見代碼裡的 imagestyletypeconver 類,該類是繼承於
expandableobjectconverter 類的,並且需要實現下面四個重載:
public override bool canconvertfrom(itypedescriptorcontext context, type sourcetype)
{
}
public override bool canconvertto(itypedescriptorcontext context, type destinationtype)
{
}
public override object convertfrom(itypedescriptorcontext context, cultureinfo culture, object value)
{
}
public override object convertto(itypedescriptorcontext context, cultureinfo culture, object value, type destinationtype)
{
}

方法二

asp.net中避免頁面多次提交的代碼:網頁特效< script language="javascript"> < !-- function disableothersubmit() {

  var obj = event.srcelement;

  var objs = document.getelementsbytagname('input');

  for(var i=0; i< objs.length; i++)

  {

  if(objs[i].type.tolowercase() == 'submit')

  {

  objs[i].disabled = true;

  }

  }

  } //--> < /script>//asp.net中避免頁面多次提交的代碼:asp.netpublic class preventmulticlick : system.web.ui.page {

  protected system.web.ui.webcontrols.button button1; protected system.web.ui.webcontrols.button button2;

  protected system.web.ui.webcontrols.linkbutton linkbutton1; protected system.web.ui.webcontrols.button button3; private void page_load(object sender, system.eventargs e)

  {

  this.getpostbackeventreference(this.button3);

  //保證 __dopostback(eventtarget, eventargument) 精確註冊 if(!ispostback)

  {

  system.text.stringbuilder sb = new system.text.stringbuilder();

  sb.append("if (typeof(page_clientvalidate) == 'function')

  {

  if (page_clientvalidate() == false)

  {

  return false;

  }

  }"); //保證考證函數的執行 sb.append("if(window.confirm('are you sure?')==false) return false; ");

  //自訂用戶端指令碼 sb.append("disableothersubmit(); ");

  // disable一切submit按鈕 sb.append(this.getpostbackeventreference(this.button3));

  //用__dopostback來提交,保證按鈕的效勞器端click工作執行 sb.append("; ");

  button3.attributes.add("onclick",sb.tostring());

  }

  } #region web form designer generated code override protected void oninit(eventargs e)

  {

// // codegen: this call is required by the asp.net web form designer. // initializecomponent();

  base.oninit(e);

  }

  /// < summary> /// required method for designer support - do not modify /// the contents of this method with the code editor. /// < /summary> private void initializecomponent()

  {

  this.button3.click += new system.eventhandler(this.button3_click); this.load += new system.eventhandler(this.page_load);

  }

  #endregion private void button3_click(object sender, system.eventargs e)

  {

  system.threading.thread.sleep(3000);

  response.write("hello world!");

  }

  } 此處只是disable掉一切的submit button, 我感覺其它的可提交控制項也是能夠經由相似的辦法來disable的.

首頁 1 2 末頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.