Click to See Complete Forum and Search --> : asp.net / jscript problem


Shooters
06-28-2006, 07:58 AM
I wonder if anybody can help with this.

I want to create a dynamic link on a page which automatically vnc me into a client pc on our intranet. The computer name is stored in a database field.

If the pc I want to connect to was called PC01, for example, I could use the following code in my aspx page:
<SCRIPT Language="JScript">
function makelink() {
linkname="vncviewer.exe PC01";
WSH=new ActiveXObject("WScript.Shell");
WSH.run(linkname);
}
<A href="#" onClick="makelink(); return false;">Run VNC</A>
</SCRIPT>

However, rather than hardcode PC01 in the script, I want to grab the relevent computer name from the database. The problem is that I can't seem to find a way to pass that variable to jscript.

Any ideas?

AlecW
06-28-2006, 10:29 AM
There are several things you could do to accomplish this, first would be to fill a drop down with a list of your servers, on a button click, you could call the JS passing in the value of the drop down.

Next would be to use some form of AJAX, use it to populate the drop down, and on a click, have it call the JS passing in the value of the server.

You could try creating the JS on the backend and then register the script so that it will run once the page is loaded. So basically, they select the server, click button, it postsback, and creates the JS, then registers it.

Lastly, you could use Atlas (if you are using 2.0) and have the button click do the above, but it looks like it is not actually posting back.

Hope one of these suggestions will put you on track.

Shooters
06-28-2006, 10:55 AM
Ah, doesn't really help, but thanks for trying.

I finally found the solution, which was far easier than I was expecting. I was able to get the variable into javascript by using...

<%
str_Variable1 = blah_blah_insertvariablehere
%>
<html>
<head>
<script language="JavaScript">
var strVariable1='<%= str_Variable1 %>';
</script>
</head>