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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problems with variable scope

Status
Not open for further replies.

mixc

Programmer
Jun 6, 1999
14
0
0
US
The scenario: a link is chosen; for certain users page A is to be called, for others page B. We tried an intermediate page that the link went to and which contained IF statements and RESPONSE.REDIRECT to go to the appropriate page. The problem is we cannot use Request.form to access any variables from the original page which contained the link. We are using IIS 4.0 so server.transfer is not an option.
 
I'm not sure what you're asking here.&nbsp;&nbsp;Can you rephrase your question? <p>nick bulka<br><a href=mailto:nick@bulka.com>nick@bulka.com</a><br><a href= > </a><br>
 
PAGE A&nbsp;&nbsp;has a link to sales<br><br>if usertype is X, i want to execute salesx.asp<br>if usertype is y, i want to execute salesy.asp <br><br>and i want access to the items on PAGEA.<br><br>here is what was done.<br><br>PAGE A linked to salestest.asp<br><br>salestest.asp checked usertype and based on that used response.redirect to execute salesx or salesy.asp but neither salesx.asp nor salesy.asp could reference any of the input fields on PAGE A.
 
Try not using Response.Redirect() at all.<br><br>Use server side includes and make salestest.asp nothing but an html shell with the decision making code to determine if you should include salesx or salesy. <br><br>This will eliminate the extra round trip and provide the included code of salesx and salesy access to the Request variables.<br><br>&lt;%<br>&nbsp;&nbsp;if ( Request(&quot;type&quot;) == 1){<br>%&gt;<br>&lt;!-- #include file=&quot;salesx.asp&quot; --&gt;<br>&lt;% }else{ %&gt;<br>&lt;!-- #include file=&quot;salesy.asp&quot; --&gt;<br>&lt;% }&nbsp;&nbsp;// end if() %&gt;<br><br>Good luck<br>Pete<br>
 
I am not sure what &quot;usertype&quot; is, if it is a form field. then you can do what you want without ASP, just ole JavaScript. Just Make the Form have no ACTION attrib.<br>like &lt;form name='myform' method='POST' onSubmit='pagesender()'&gt;<br><br>and then javascript like this<br><br>function pagesender()<br>{<br>&nbsp;&nbsp;if(document.myform.whateverfield.value == &quot;A&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent.location=salesx.asp;<br>&nbsp;&nbsp;else&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(document.myform.whateverfield.value == &quot;B&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent.location=saley.asp;<br>&nbsp;&nbsp;}<br>}<br>All of your form info will be intact<br>THIS MIGHT NOT WORK IF RESPONSE.BUFFER=TRUE<br><br>Or, if it is something predermined before the user files out the form (like on a Session variable or something) then just assign a variable when the user first gets to the page<br>and base which page they goto on that &lt;form action=&quot;&lt;%=var%&gt;&quot;<br><br>GL<br>Jlowery&nbsp;&nbsp;&nbsp;<br>&nbsp;<br>
 
Pete,<br>&nbsp;&nbsp;&nbsp;You can't conditionally include files.&nbsp;&nbsp;The include directive gets preprocessed before any scripting code executes, so both files would always get included.<br>&nbsp;&nbsp;&nbsp;IIS 5 gives you the ability to conditionally include files via the server.execute method.<br> <p>nick bulka<br><a href=mailto:nick@bulka.com>nick@bulka.com</a><br><a href= > </a><br>
 
I do it all the time nick<br><br>I even use the same technique in JSP<br><br>-pete
 
Hello all,<br><br>To clarify my original post and Nick's comment. Yes, the files will be included on the server then the scripting ingine will run. <br><br>When the engine reaches your server side scripting conditional statement it will jump around a condition that evaluates to 'false'. None of the server scripting code will execute, and none of the HTML will be sent to the browser. The only perfomance issue is the in memory concatination of all the '#include'ed files. In most cases these files are cached and the effect on performance will likely be negligable.<br><br>-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top