Three asp.net Verification Code (1/2)

Source: Internet
Author: User

<! --
The article provides three different styles of asp tutorial. net graphic verification code.

<% @ Page language = "c #" contenttype = "text/html" responseencoding = "gb2312" %>
<! Doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.bKjia. c0m/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> Verification code for three asp.net tutorials </title>
</Head>

<Body>
<%
<PC3: 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 function is [designerserializationvisibility (designerserializationvisibility. content)]
And typeconverter (typeof (imagestyletypeconver.
[Designerserializationvisibility (designerserializationvisibility. content)] The system prompts that the property is changed to generate.
Imagestyle-imgbgcolor = "white", for typeconverter (typeof (imagestyletypeconver ))
It is mainly used for type conversion. For details, see the imagestyletypeconver class in the Code. This class is inherited from
Expandableobjectconverter class, and the following four overloading needs to be implemented:
Public override bool canconvertfrom (itypedescriptorcontext context, type sourcetype)
{
}
Public override bool canconvertion (itypedescriptorcontext context, type destinationtype)
{
}
Public override object convertfrom (itypedescriptorcontext context, cultureinfo culture, object value)
{
}
Public override object convertion (itypedescriptorcontext context, cultureinfo culture, object value, type destinationtype)
{
}

Method 2

Code to avoid multiple page submissions in asp.net: webpage special effect <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> // code to avoid multiple page submissions in 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 );

// Ensure that _ dopostback (eventtarget, eventargument) precisely registers if (! Ispostback)

{

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

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

{

If (page_clientvalidate () = false)

{

Return false;

}

} "); // Ensure that the execution of the validation function sb. append (" if (window. confirm ('Are you sure? ') = False) return false ;");

// Customize the client script sb. append ("disableothersubmit ();");

// Disable all submit buttons sb. append (this. getpostbackeventreference (this. button3 ));

// Use _ dopostback to submit the task. Make sure that the click operation on the worker side of the button is executed by 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! ");

}

} Here, only the submit button is disable. I feel that other submit controls can also be disable in a similar way.

1 2

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.