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 >