简体   繁体   中英

Transfer VB.NET variable to JavaScript

** *VB.HTML

@Code

Dim SS_ID = Request.QueryString("SS_ID")

Dim initial_QRY



Dim ctrRecord

If SS_ID <> "" then

    initial_QRY = "SELECT * FROM Tbl_rsSKUSetup WHERE SKUSetup_ItemID='" & SS_ID & "'"

    ctrRecord = db.Query(initial_QRY).Count

        If ctrRecord = 0 Then

            System.Diagnostics.Process.Start("C:\Users\ushuam00\Documents\My Web Sites\EmptySite5\_Files\skuSetupGenericData.xlsm")
       Else If ctrRecord > 0 Then



       Else 

End Code

** *JavaScript

function alertCounter(){
    alert('');
}

I want ctrRecord to be placed inside alter of JavaScript. Now I have the VBHTML on event "onload" calling alertCounter() All I have to see if I can capture ctrRecord so I can display it under alert.

I got this simple solution

display the ctrRecord inside the body where your VB.net code rest

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title></title>
    </head>
    <body>
        @ctrRecord
    </body>
</html>

then call JS via iFrame using onload event

Javascript

  function alertCounter(){
   alert(searchFrame.document.body.innerText);
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM