User1045460610 posted
I'm working on a way to test our code to pass the hostid to our automated attendance web site, with encription, AES Compliant, Salt Passphrase, expiring url.
I get an error testing some code to pass a parameter to a function to post a hostid with url from our web portal to our web site. The error "Attribute name must be followed by an equal sign and a value" as listed on the script below.
We won't have a code behind page since the script will be on a user control in our third party web portal. It looks like I would need to declare a variable and then assign it the text String for a test. Then just comment out the text variable declaration
(var hostID = '123456';).
What's a way I can test that out and be able to see that? It might be that I could write the variable to the console and view it in the browser console.
How do a pass a parameter to function btoaUTF16("hello") for testing with a text variable, and then in runtime it will be a btoaUTF16(@@HostID) variable from the environment.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="instructorlinkhostid.aspx.cs" Inherits="instructorlinkhostid" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test</title>
<script type="text/javascript">
var hostID = '123456';
var hostIDText = '123456';
</script>
<script>
function myFunctionHead()
{
document.getElementById("script in head").innerHTML = "script is in head";
}
</script>
<script>
function btoaUTF16(sString)
{
var aUTF16CodeUnits = new Uint16Array(sString.length);
Array.prototype.forEach.call(aUTF16CodeUnits, function(el, idx, arr) { arr[idx] = sString.charCodeAt(idx); });
return btoa(String.fromCharCode.apply(null, new Uint8Array(aUTF16CodeUnits.buffer)));
}
</script>
</head>
<body>
<p><a title="Attendance Instructor" href="https://attendance.....com/instructorcourse.aspx?HostID=@@HostID" target="_blank" rel="noopener">Attendance Instructor</a></p>
<h1>Encode</h1>
<p id="Encode">Encode</p>
<%--<button type="button" onclick="btoaUTF16("hello")">Try it</button>--%> <%--attribute name must be followed by an equal sign and a value--%>
<button type="button" onclick="btoaUTF16(hostID)">Try it</button>
<h1>Scipt from Head</h1>
<p id="script in head">Script in Head</p>
<button type="button" onclick="myFunctionHead()">Try it</button>
<h1>Script From Body</h1>
<p id="script in body">Script in Body</p>
<button type="button" onclick="myFunctionBody()">Try it</button>
<script>
function myFunctionBody()
{
document.getElementById("script in body").innerHTML = "script is in body";
}
</script>
<form id="form1" runat="server">
<div>
</div>
</form>
<%-- Testing Code
js encode
function btoaUTF16(sString)
{
var aUTF16CodeUnits = new Uint16Array(sString.length);
Array.prototype.forEach.call(aUTF16CodeUnits, function(el, idx, arr) { arr[idx] = sString.charCodeAt(idx); });
return btoa(String.fromCharCode.apply(null, new Uint8Array(aUTF16CodeUnits.buffer)));
}
console.log(btoaUTF16("hello")) // result aABlAGwAbABvAA==
C # decode
byte[] data = Convert.FromBase64String("aABlAGwAbABvAA==");
string decodedString = Encoding.UTF8.GetString(data);
Response.Write(decodedString);
--%>
</body>
</html>