Html/asp communicates with. Net to directly access the DLL generated by. net.

Source: Internet
Author: User
I learned about the Ajax. dll and ajaxpro frameworks in the previous section and found many interesting functions.
Among them, it provides an excellent mode for communication between static pages and. net. The idea is to use. Net to establish a process method for access by JS, and the intermediate communication uses the Ajax. dll framework.
For details about the configuration of Ajax. dll in. net, refer
In this example, the. NET method is called on the HTML page to extract the MD5 value directly.

JS file, used to read methods in. net // ----------------------------------------------------------------
Function Getmd5 ()
{
VaRPass=Document. getelementbyid ("Txtpass"). Value;
Webform1.md5 (Pass, strmd5 );
}


Function Strmd5 (RES)
{
Document. getelementbyid (
"Passmd5"). Value=Res. value;
}

// -----------------------------------------------------------------

. Net. < Ajax. ajaxmethod () > _
Public   Function MD5 ( Byval S As   String ) As   String
Return System. Web. Security. formsauthentication. hashpasswordforstoringinconfigfile (S, " MD5 " ). Tolower (). substring ( 8 , 16 )
End Function

Direct call < Html >
< Head >
< Title > Test </ Title >
< Script Language = "JavaScript" SRC = "Ajax/common. ashx" > </ Script >
< Script Language = "JavaScript" SRC = "Ajax/ajaxtest_dll.webform1, ajaxtest_dll.ashx" > </ Script >
< Script Language = "JavaScript" SRC = "Ajaxtest. js" > </ Script >
</ Head >
< Body Ms_positioning = "Gridlayout" >
< Input ID = "Txtpass" Style = "Z-INDEX: 101; left: 64px; position: absolute; top: 56px" Type = "Text"
Name
= "Text1" > < Input ID = "Passmd5" Style = "Z-INDEX: 102; left: 64px; position: absolute; top: 80px" Type = "Text"
Name
= "Text2" > < Input ID = "Button1" Style = "Z-INDEX: 103; left: 224px; position: absolute; top: 56px" Type = "Button"
Value
= "Button" Name = "Button1" Onclick = "Getmd5 ();" >   < Input ID = "Txttel" Style = "Z-INDEX: 104; left: 64px; position: absolute; top: 160px" Type = "Text"
Name
= "Text1" >

body >
HTML >

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.