Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp page to generate another asp page? 1

Status
Not open for further replies.

jlsmithhartfiel

Programmer
Jan 7, 2002
336
US
Hi!

I have a cool htm file that uses javascript to open another htm page based on what you type in a text box.

I'd like to do the same to open an asp page from what I type in a text box.

Reason why I want this:
1. remote debugging of customer site
2. do not have ftp access, and they do not want me to write to the production servers

I'm having trouble with this...I can get the text displayed in another window, but it won't render it. Any ideas?

TIA,
Jessica

=======================
initial page
it writes what you have to frame at right; I also have it opening a new window in hopes that it would magically work :)

All credits to:
/* Created by Hezekiel Randolph * * uniment.tripod.com *
\* anon4016@yahoo.com */
=======================
Code:
<!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Frameset//EN&quot;>
<html>
 <head>
  <title>
   ASPMaker
  </title>
 </head>

<script type=&quot;text/javascript&quot;>
<!--

/* Created by Hezekiel Randolph * *      uniment.tripod.com      *
\*      anon4016@yahoo.com      */

/*
HTMaker Script
IE 4+ | NS 4+ | Mozilla 0.x | Opera 5+ | Icab -- Sorry, it makes Icab frown ;-(
Konquerer 2.1.1 (Using KDE 2.1.2) has been tested, doesn't work.
Other browsers not tested.
*/

// Query:
var q=new Array();
q.string=location.search.substring(1,location.search.length);
q.toString=function() {return this.string;};
q.pairs=q.string.split('&');
for (var i = 0; i < q.pairs.length; i++) {
 var cp=q.pairs[i].split(&quot;=&quot;);
 q[cp[0]]=q[i]=unescape(cp[1]);
}


// universal Variables:
var l, r, lo, ld, rd, ldt;
var ie = document.all?1:0;
var ns = document.layers?1:0;
var dom = (!ie && document.getElementById)?1:0;
var lForm = 'document.'+(ie?'all':'forms.Z');
var lTxet = lForm+'.txet';
var txetSrc = &quot;&quot;;
// left frame source:
{
 var src =
 '<'+'!DOCTYPE html PUBLIC &quot;-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN&quot;>'+
 // IE (6 and earlier) doesn't support CSS with an XHTML doctype,
 // so it's an HTML doctype instead.

 '<html><head><title><\/title><style><'+'!--\n'+
// Title to keep Icab from frowning
 'input {font:menu;}'+
 'textarea {font-family: lucida console; font-size: 12px;}'+
 '--'+'><\/style><\/head><body bgcolor=&quot;#fff3dd&quot;>'+
 (ie?'':'<form name=&quot;Z&quot;>')+
 '<textarea name=&quot;txet&quot;'+(dom?'':' rows=&quot;20&quot; cols=&quot;44&quot; wrap=&quot;off&quot;')+' style=&quot;height:90%;width:100%&quot;>'+
 txetSrc+
 '<\/textarea>'+
 '<input type=&quot;button&quot; value=&quot;Test Source&quot; accesskey=&quot;a&quot; onclick=&quot;parent.document.maket('+lTxet+'.value);'+lTxet+'.focus();&quot;>'+
 (ie?'':'<\/form>')+
 '<\/body><\/html>';
 document.leftSrc = src;
}


function main() { // Call function main because frameset's don't accept scripts.
 if (!window.frames || !frames[0] || !frames[0].document) {
  alert('Sorry, but your browser cannot handle this application.');
  return 0;
 }
// Initialize universal frame variables:
 l = frames[0];
 r = frames[1];
 lo = frames[2];
 ld = frames[0].document;
 rd = frames[1].document;
// Initialize left frame:
 setLeft();
 if (typeof lo.document.load == &quot;function&quot;)
  lo.document.load();
}

function setLeft() {
 var okay = 1;
 if (ns) okay = checkLeft();
 if (okay) {
  ldt = eval('frames[0].'+lTxet);
 }
}

// Function tests if Netscape failed to write left frame
// correctly: if failed, fixes it (bug found in NS 4.08; I haven't tested
// other document.layers-accepting browsers. If still failed, alerts user
function checkLeft() {
 ld = frames[0].document;
 if (!ld.Z || !ld.Z.txet) {
  ld.write('');
  ld.close();
 }
 ld = frames[0].document;
 if (!ld.Z || !ld.Z.txet) {
  window.alert(&quot;There has been an error loading HTMaker.&quot;);
  return 0;
 }
 else return 1;
}

document.maket=function(myHTML) {
 myHTML=escape(escape(myHTML));
 setTimeout(&quot;rd.open();rd.write(unescape(unescape('&quot;+myHTML+&quot;')));rd.close();document.setTitle(rd.title);&quot;,0);
 jls = window.open(&quot;avgprice2.asp&quot;);
 jls.document.open();
 jls.document.write(unescape(unescape(myHTML)));
 jls.document.close();
 //setTimeout(&quot;rd.location=\&quot;javascript:(unescape(unescape('&quot;+myHTML+&quot;')));\&quot;&quot;,0);
}

document.setTitle=function(myTitle) {
 var re=/^\s*$/;
 if (!re.test(myTitle))
  document.title=myTitle + &quot; -- HTMaker&quot;;
 else
  document.title=&quot;HTMaker&quot;;
}

document.changeValue=function(txetSrc) {
 ldt.value=txetSrc;
}


// -->
</script>

<noscript>
 <p>
  You need a JavaScript-Enabled Browser to run this application,
  <Br>
  preferrably Mozilla (Netscape 6.x) or the latest version of Internet Explorer.
 </p>
 <p>
  <a href=&quot;[URL unfurl="true"]http://www.mozilla.org&quot;>Mozilla</a>,[/URL] what Netscape 6 is founded on
 </p>
 <p>
  <a href=&quot;[URL unfurl="true"]http://www.microsoft.com&quot;>Microsoft</a>,[/URL] the makers of Internet Explorer.
 </p>
</noscript>
<!---><!--->
 <frameset cols=&quot;50%,*,0&quot; onload=&quot;main()&quot;>
  <frame name=&quot;lefty&quot; src=&quot;javascript:parent.document.leftSrc;&quot;>
  <frame name=&quot;righty&quot; src=&quot;javascript:'<html><body><\/body><\/html>'&quot;>
  <frame name=&quot;loader&quot; src=&quot;javascript:parent.q.load?void(location=parent.q.load):''&quot; noresize=&quot;noresize&quot;>
 </frameset>
</html>
=======================

sample text to put into text box.
=======================
Code:
<% @language = vbscript %>
<%
Option Explicit

' Declare variables
dim iRows, iCols
iRows = &quot;5&quot;
iCols = &quot;10&quot;
%>

<html>
<head>
<title>test page</title>
</head>

<body>
test page<br>
<%=iRows%> by <%=iCols%>
</body>
</html>
=======================

Jessica [ponytails2]
 
The new ASP page will need to be written out to the file system (as, say,
Code:
tempcheck.asp
) in order for the web server to process it.

Alternately I believe you could have a standard &quot;
Code:
tempcheck.asp
&quot; page that
Code:
eval
uates what you send it, but it would be a huge security hole (since anyone finding out about it could send it any ASP they wanted).
 
I thought of doing using the file system, but I'm not supposed to physically write files to the server. :(

The site is password protected, so I'm not too worried about having this page there...in addition it won't be a permanent fixture. Can you point me to an example of the 2nd option?

I still need to evaluate whether to do this or not, but would like to know how.

THanks!


Jessica [ponytails2]
 
If you can't write anything to the server (so it can be executed), then you're a lot more limited. The Eval suggestion I made will work, but the ASP you send it is pretty limited. You can't dimension variables, for example, and it can't remember anything from one line to the next.

You can do some minor things like
Code:
Response.Write
-ing out server variables, etc., so it's not worthless, but it's probably not going to do what you want.

That said, I wrote one up anyway. The form submits to itself so in my example the page should be called
Code:
activate.asp
:
Code:
<%@LANGUAGE=&quot;VBSCRIPT&quot; CODEPAGE=&quot;1252&quot;%>
<html>
<head>
<title>Activator</title>
</head>
<body>
<%
If Request.Form(&quot;activate&quot;) = &quot;Activate&quot; Then
    Dim aryCommands, i
    aryCommands = Split(Request.Form(&quot;commands&quot;), vbCrLf)
    Response.Write(&quot;<hr>&quot;)
    For i = 0 to Ubound(aryCommands)
        If Trim(aryCommands(i)) <> &quot;&quot; Then Eval(aryCommands(i))
    Next
    Response.Write(&quot;<hr><br>&quot;)
End If
%>
<form action=&quot;activate.asp&quot; method=&quot;post&quot;>
<textarea name=&quot;commands&quot; cols=&quot;80&quot; rows=&quot;5&quot;>
    <%=Request.Form(&quot;body&quot;)%>
</textarea>
<br>
<input name=&quot;activate&quot; type=&quot;submit&quot; value=&quot;Activate&quot;>
</form>
</body>
</html>
 
I forgot to mention, just in case it wasn't clear: you type ASP commands into the textarea, separated by just hitting the Enter key, and then hit the &quot;Activate&quot; button.
 
Is it that you aren't allowed to put files onto the server, or just that you don't have permissions remotely to do so?

They can't expect you to develop their site if you can't put pages on their server :p

Having said that, it's also garden-variety-common practice to have a development server. Does your ASP have to interact with databases a lot? If not, why not just install PWS on your home machine (as well as anything else you need e.g. MSXML, WSH, CDOsys, etc) and develop it there, and then upload it to their server when it's been tested?

codestorm
Newbie Life Member.
Fire bad. Tree pretty. - Buffy
<insert witticism here>
 
You know, when you say you're not supposed to write anything to the server... does it count if you're just rewriting a file that's already on the server? Maybe that sounds cheesy, but it's not like you'll be generating all kinds of files or anything -- you'll just be writing over one file repeatedly.
 
Thanks Genimuse and codestorm! Good points!

Thanks Genimuse for the example. I'll give it a shot.

Basically I send files to their tech who uploads them. There's some agreement with their hosting facility that is null & void if a 3rd-party (me) installs things on their webserver. Not sure how it would be to rewrite one that they already put there...might be a very fine line! :) But I may be able to go with that.

I do have a development site here. Only problem is data. Their databases are huge. What works fine with my sampling of data, croaks on the full set. :( Makes me look not so competent.

I wrote an asp page that lets me write sql code on the fly, but a lot of my calculations are in asp...which is where I'm at now.

I'll run with these ideas and see where it gets me.

Thanks!

Jessica [ponytails2]
 
Understand that in the &quot;rewriting&quot; scenario you won't have to send them a file to rewrite -- you'll only have to send them the two files once, and the code in one of them will be rewriting the other.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top