Multiple verification codes need to be displayed on a single page of ASP.

Source: Internet
Author: User
Tags base64

1. Background gets the validation byte stream, which is returned to the front end as a string.

         Public actionresult getvalidategraphic ()        {            varnew  validatecode ();             var code = Validate. Createvalidatecode (4);             var image = Validate. Createvalidategraphic (code);            session["validatecode"] = code; //             return  Content (convert.tobase64string (image));        }

2, the front desk with Ajax access

    function () {        $.ajax ({            false,            "/login/getvalidategraphic",              function  (data) {                $ (' #yxValidateCode '). attr (' src ', ' data:image/png;base64, ' + data);                $ (' #bqfValidateCode '). attr (' src ', ' data:image/png;base64, ' + data);                $ (' #glValidateCode '). attr (' src ', ' data:image/png;base64, ' + Data ');}        );    }

This allows you to display multiple identical verification codes on the page.

So what is this? This is the data URI scheme. URI scheme is defined in RFC2397 to embed some small data directly into a Web page, eliminating the need to load it from an external file.

We can write images directly into an HTML file, which saves a picture request, and the downside is that the browser cannot cache the image.

Multiple verification codes need to be displayed on a single page of ASP.

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.