What happened to client side code???

G

Guest

I am having a really hard time trying to get some client side code hooked up
in VS2005, ASP 2.0.

The code is in an .inc file (vbscript). The first problem I am encountering
is the ASP.NET page doesn't like vbscript and throws fits about the syntax.
Second, the page throws fits about the server side code tags (<% ...
%>),...are these supported anymore? Third, when I set the onclick event of a
client side HTML button it does not recognize the "public" method that I
specify (that is in the include file). I feel like there is some key piece of
information that I am missing that will make all of these issues fall into
place.

Essentially, what I need to do is access one or more local files on the
computer based on parameters that are sent to the server for processing. For
example, if a user clicks on a link I can pass a parameter to the server that
specifies the report the user is requesting, I can then return some
information about where to get the report (the file path...on another Report
Server), and then also where to put this report on the Users machine (client
code).

When I implemented this in ASP, I got it to work flawlessly and I was able
to do some string manipulation to get the client side code and the server
side code to work together nicely. I would like to get it updated to work
with our new ASP 2.0 webpages.

Any ideas on "re-inventing the wheel" in .NET?
Thanks,
- Mike
 
G

Guest

Just use the Page.ClientScript.RegisterClientScriptBlock to embed your client
script into the page. You can do this in the Page_Load event handler. You can
even load the script text from a file off the file system if you want.

Peter
 
G

Guest

Peter,
Thanks for the suggestion. It did get me further than I was. But, I am still
running into at least one issue. I can see the client code when I View Source
on the page. The problem seems to be that the client side button control does
not see the method that I am calling. When I run the project an error comes
up on the onclick="SystemTest()", when I highlight the onclick to get more
info. it just shows {...} and no further information on the error. (Note, the
script was in vbscript, but I updated it to work with VB.)

Here is the sample code:
....
<SCRIPT LANGUAGE="VB">
Sub TestSystem()

Dim shl_Test As Object
Dim lExecRet_Test AS Long
Dim sCalc_Path As String

sCalc_Path = "C:\WINDOWS\system32\calc.exe"
shl_Test = CreateObject("WScript.Shell")
lExecRet_Test = Shl_Test.Run(sCalc_Path,1,true)

END Sub
</SCRIPT>
<div>
<input id="Button1" style="z-index: 100; left: 136px; width: 155px;
position: absolute;
top: 106px; height: 57px" type="button" value="button"
onclick="TestSystem()" />
</div>
</form>
</body>
</html>

Any ideas?
Thanks,
- Mike
 
G

Guest

Try this:

<SCRIPT LANGUAGE="VBScript">
Sub TestSystem()


Dim shl_Test
Dim lExecRet_Test
Dim sCalc_Path

sCalc_Path = "C:\WINDOWS\system32\calc.exe"
set shl_Test = CreateObject("WScript.Shell")
lExecRet_Test = Shl_Test.Run(sCalc_Path,1,true)

END Sub
</SCRIPT>
<div>
<input id="Button1" style="z-index: 100; left: 136px; width: 155px;
position: absolute;
top: 106px; height: 57px" type="button" value="button"
onclick="TestSystem()" />
</div>
</form>
</body>
</html>



--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
 
G

Guest

Peter,
Thanks. I got it working. I pasted the code into the page, rather than using
the Register method and then realized that the code was the problem. More
specifically the language tag, the script tag being capatilized and the
absence of the type attribute (the code I used was my original vbscript
code). Once I got those sorted out, it worked nicely. Then I moved it back to
the include file and used the Register method and it worked fine.
Thanks for taking the time on this, I really appreciate it!
- Mike
 
M

Mark Rae [MVP]

Is it possible to translate that script in javascript?

<script type="text/javascript>
function TestSystem()
{
var shl_Test;
var lExecRet_Test;
var sCalc_Path;

sCalc_Path = "C:\\WINDOWS\\system32\\calc.exe";
shl_Test = new ActiveXObject("WScript.Shell");
lExecRet_Test = shl_Test.Run(sCalc_Path,1,true);
}
</script>

N. B. I haven't tested this...
 
G

Guest

Thank you, it works.
--
JLobo


Mark Rae said:
<script type="text/javascript>
function TestSystem()
{
var shl_Test;
var lExecRet_Test;
var sCalc_Path;

sCalc_Path = "C:\\WINDOWS\\system32\\calc.exe";
shl_Test = new ActiveXObject("WScript.Shell");
lExecRet_Test = shl_Test.Run(sCalc_Path,1,true);
}
</script>

N. B. I haven't tested this...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top