ASP 3.0 - Server.Execute Problems: Suffering from “ASP Amnesia”

前端 未结 3 1163
清歌不尽
清歌不尽 2021-01-27 04:21

Created Two ASP 3.0 Files: -Main.asp -Colors.asp


Main.asp

<%

Blah Blah Blah...

If sColor = true then
Server.Execute \"Colors.asp\"
End If
\'         


        
相关标签:
3条回答
  • 2021-01-27 04:35

    The documentation (http://msdn.microsoft.com/en-us/library/ms525849(v=vs.90).aspx) says :

    The Execute method calls an .asp file, and processes it as if it were part of the calling ASP script. The Execute method is similar to a procedure call in many programming languages.

    If it's similar to a procedure call I guess it makes sense to scope the variables too. As was said by Dee, declare the variables in the calling page and it should work.

    0 讨论(0)
  • 2021-01-27 04:37

    The executed page has no access to local variables in the calling page and conversely neither does the calling page have access to local variables in the executed page. Whether you declare them or not makes no difference the two scripts are not executing in the same context let alone the same scope.

    Calling Server.Execute() effectively causes the executed page to be executed in isolation and its output incorporated into the output of the calling page at the point it is called:

    After IIS processes the .asp file specified in the input parameter to Server.Execute, the response is returned to the calling ASP script.

    The following collections and properties are available to the executed ASP page:

    * Application variables, even if they are set in the calling page.
    * Session properties, even if they are set in the calling page.
    * Server variables and properties, even if they are set in the calling page.
    * Request collections and properties, even if they are set in the calling page. This includes Form and QueryString data passed to the calling page.
    * Response collections and properties. The executed .asp file may modify HTTP headers. However, as with any .asp file, if the executed .asp file attempts to modify HTTP headers after it sends a response to the client, it generates an error.
    

    If a file is included in the calling page by using #include, the executed .asp will not use it. For example, you may have a subroutine in a file that is included in your calling page, but the executed .asp will not recognize the subroutine name. You must include the file in each executed .asp that requires the subroutine.

    If you want to do variable passing between scripts you are much better off using include directives. If you must do variable passing then you will have to jury rig something using the Application or Session object and I would not advise that.

    0 讨论(0)
  • 2021-01-27 04:55

    you probably need to dim the variables in the calling page (?)

    0 讨论(0)
提交回复
热议问题