I'm currently working on a web application and I need to retrieve data about the local environment of the machine that is accessing the application. To achieve this, I am using a small JavaScript script like the one below:
<script language="javascript">
function GetUserName()
{
// Retrieve username of client machine
var wshell = new ActiveXObject("WScript.Shell");
var arpege = wshell.ExpandEnvironmentStrings("%USERNAME%");
document.getElementById("arpege").value=arpege;
}
</script>
<input type=hidden id="arpege" runat=server />
The issue I'm facing is that this script only executes after the page has loaded, making it inaccessible during the initial load...
My code for the page load looks like this:
protected void Page_Load(object sender, EventArgs e)
{
myConnection.ConnectionString = ActionSource.ConnectionString;
myConnection.Open();
String account = arpege.value;
...
}
However, all I get in the "account" variable is an empty string...
Any assistance would be greatly appreciated,
Quentin