Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Q: Including from file in a ASP

Reply
Thread Tools

Q: Including from file in a ASP

 
 
HJK
Guest
Posts: n/a
 
      01-24-2004
I'm not familiar with ASP and server side scripting.

I want to include JScript from file. Can it be done ?

Its the part with the Options code I want to put in a Options.js
file not accessible from internet side. It will also be nice to extend it
to include
from different .js files later.

See my ASP example below wich I get to work in IIS 5.0

<% @Language = "JScript" %>

<%
// want to run the following code from file...
var Options
Options="\<option value=\>Line1\<\/option\>";
Options+="\<option value=\>Line2\<\/option\>";
Options+="\<option value=\>Line3\<\/option\>";
Options+="\<option value=\>Line4\<\/option\>";
%>

<html>

<head>

</head>


<form method="post" name="myform">


<table border="1" >
<tr>
<select name="MyListBox" size="10" style="FONT-FAMILY: Trebuchet MS">
<%
Response.write(Options);
%>

</select>
</tr>


</table>
</form>

</body>
</html>


 
Reply With Quote
 
 
 
 
Aaron Bertrand [MVP]
Guest
Posts: n/a
 
      01-24-2004
> See my ASP example below wich I get to work in IIS 5.0

Did you try <!--#include file=options.js--> or <script language=jscript
runat=server src=options.js></script>?

A couple of notes:

- a user typing in http://www.yoursite.com/yourfile.js will be able to read
the file in plain text. If you have anything you want to keep "secret" from
casual viewers, use the ASP extension. See http://www.aspfaq.com/2163 and
http://www.aspfaq.com/2269

- if your goal is to use a .js file in both server-side and client-side
script, see http://www.aspfaq.com/2208

- if you are mixing JScript and VBScript in a single page, there are "order
of operations" issues to consider; see http://www.aspfaq.com/2045

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


 
Reply With Quote
 
 
 
 
HJK
Guest
Posts: n/a
 
      01-24-2004

"Aaron Bertrand [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> > See my ASP example below wich I get to work in IIS 5.0

>
> Did you try <!--#include file=options.js--> or <script language=jscript
> runat=server src=options.js></script>?
>


Thank you. Include works well and imports the listbox content OK.
I actually ended up using <% Server.Execute("sites.ASP") %>

However I struggle to protect my javascripts in existing html pages. Thats
my goal.

One example is
http://home.online.no/~jensts/Satellite/Elevation.htm

It calls a jscript using <script src="filename" ></script>

Inside the pages I use onchange trigged functions from the jscript file.

I've tried for several days to make it as ASP but the only way to get it to
work is to give the scriptfile read access from internet side.

Also to run the script containing script functions at server or as
Server.Execute("file.ASP") causes the onchange event to
result in uknown object.

Perhaps ASP is not the best way of doing this ? - Could there be better
alternatives for this?


 
Reply With Quote
 
Aaron Bertrand [MVP]
Guest
Posts: n/a
 
      01-24-2004
> Perhaps ASP is not the best way of doing this ? - Could there be better
> alternatives for this?


For hiding client-side JavaScript? If my browser can see it (and it has to
in order to run it), so can I. So, if you don't want anyone to see it
online, don't put it on the web. If you don't want anyone to see it period,
delete it from your computer and uninstall undelete.

http://www.aspfaq.com/2175

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Including a Javascript external file from the <body> part of an HTML file davidemazza82@gmail.com Javascript 2 09-26-2007 10:37 AM
including one XML file in another XML file Johan XML 20 02-27-2007 04:29 PM
Error while including a new include file in ASP Sarath ASP General 9 07-18-2005 02:10 PM
ASP.Net page not including Javascript file. Joseph Ferris ASP .Net 3 04-21-2005 12:27 PM
including one aspx file in another aspx file vish ASP .Net 2 07-16-2003 10:29 PM



Advertisments