C # voice read Verification Code

Source: Internet
Author: User

<Tr>
<Td class = "right">
<Span> * </span> Verification Code: </td>
<Td width = "165px">
<Input name = "checkcode" type = "text" maxlength = "4" class = "login_input" style = "width: 80px"
Id = "checkcode" runat = "server"/> </td>
<Td width = "146px">
Height = "40px" alt = "can't see clearly, change to" title = "can't see clearly, change to"/> </td>
<Td class = "left">
Onclick = "playvoice ('player');" align = "absmiddle"/>
</Td>
</Tr>

========================================================== ========================================================== ========================

<Script language = "javascript" type = "text/javascript" event = "onkeydown" for = "document">

If (event. keyCode = 81 & event. altKey)
{
Document. suggestForm. verifycode. focus ();
Playvoice ("player ");
}

</Script>

<Script type = "text/javascript" language = "javascript">
Function reloadcode ()
{
Var verify = document. getElementById ('safecode ');
Verify. setAttribute ('src', '../Common/getcode. aspx? '+ Math. random ());
}
Function playvoice (id)
{
Var voiceid = document. getElementById (id );
Voiceid. innerHTML = "<embed id = 'sound _ play' name = 'sound _ play' src = 'sound/sound_play.swf? "+ (New Date (). getTime () + "'flashvars = 'isplay = 1 & url = CodeVoice. aspx & code = "+ Math. random () + "'width = '0' height = '0' allowScriptAccess = 'always 'Type = 'application/x-shockwave-flash' pluginspage = 'HTTP: // www.macromedia.com/go/getflashplayer'/> </embed> ";
}
</Script>

Note:

1. Set Registe. aspx to the root directory. (The Voice function cannot be used if it is placed under a folder. The reason is not clear)

2. The files stored in the sound folder are: begin.mp3?end=and sound_play.swf.

CodeVoice. aspx in the root directory (delete all Page code and leave only header files)

The cs code is as follows:

Protected void Page_Load (object sender, EventArgs e)
{
// Read and verify the code to generate the MP3 package.
Response. ContentType = "audio/mpeg ";
Response. WriteFile ("Sound/begin.pdf ");
String checkCode = "";
If (Session ["CheckCode"]! = Null)
{
CheckCode = Session ["CheckCode"]. ToString ();
}
If (checkCode. Length> 0)
For (int I = 0; I <checkCode. Length; I ++)
{
Response. WriteFile ("Sound/" + checkCode [I] + ". mp3 ");
}
Response. WriteFile ("Sound/Endpoint ");
}

 

From: hongjiaoli Column

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.