Three ASP.net Verification Code code (1/2)

Source: Internet
Author: User

<!--
This article provides three different styles of ASP tutorials. NET graphics Verification code.

<%@ 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 ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> three asp.net tutorial verification code code </title>

<body>
<%
<cc1:authcode id= "Authcode1" runat= "Server"
Imagestyle-imgbgcolor= "White" imagestyle-imgbordercolor= "Deeps tutorial Kyblue" imagestyle-imgnoisecolor= "Ivory" imagestyle-textcolor1= "Azure"
imagestyle-textcolor2= "Ghostwhite"/>

The key to implementing this functionality is [DesignerSerializationVisibility (designerserializationvisibility.content)]
and TypeConverter (typeof (Imagestyletypeconver)) These two places.
[DesignerSerializationVisibility (Designerserializationvisibility.content)] Prompt property to change a good build
Imagestyle-imgbgcolor= "White" This code, as for TypeConverter (typeof (Imagestyletypeconver))
is mainly used for type conversion, specifically see the Imagestyletypeconver class in the code, which inherits from the
Expandableobjectconverter class, and you need to implement the following four overloads:
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 )
{
}

Method Two

asp.net code to avoid multiple submissions of pages: Web effects < 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 code to avoid multiple submissions from the page: 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);

Guaranteed __doPostBack (Eventtarget, eventargument) Accurate registration if (!ispostback)

{

System.Text.StringBuilder sb = new System.Text.StringBuilder ();

Sb.append ("If" (typeof (page_clientvalidate) = = ' function ')

{

if (page_clientvalidate () = = False)

{

return false;

}

}"); To ensure the execution of textual research functions sb.append ("if (window.confirm) (' Are you sure? ') ==false) return false; ");

Custom client Script Sb.append ("Disableothersubmit ();");

Disable all Submit button Sb.append (This.getpostbackeventreference (This.button3));

With __doPostBack to submit, to ensure that the button server click work Execution Sb.append (";");

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

}

#region Web Form Designer generated code override protected void OnInit (EventArgs e)

{

Codegen:this the call are 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 ' with the Cod E 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!");

}

Here is just disable the submit button, and I feel that other submissions can be disable by similar methods.

Home 1 2 last page
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.