传递参数,通过使用Server.Execute? [英] Passing a parameter through server.execute?

查看:475
本文介绍了传递参数,通过使用Server.Execute?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有可能通过使用Server.Execute

要传递参数

Fx的。我在我的 site.asp 中频情景,我需要 functions.asp一个东西=&放大器;?ID = 123 执行。这可能吗?!

在site.asp:

 昏暗的ID
ID = 123如果B =然后
  使用Server.Execute(functions.asp一个=东西&放大器;?编号=与& id)的
其他
  的Response.Write(没有办法花花公子)
万一

在functions.asp

  A =的Request.QueryString(A)
ID =的Request.QueryString(ID)如果=东西和CINT(ID)> 100则
  回复于(是这样花花公子)
其他
  的Response.Write(没有办法花花公子)
万一


解决方案

您不能使用使用Server.Execute 查询字符串,它是在的官方文档

<击>你可以做的要好得多:你可以直接访问变量 ID site.asp functions.asp ,你也可以声明并设置另一个变量, A

- site.asp:

 昏暗的身份证件,
ID = 123
A =东西
使用Server.Execute(functions.asp)

- functions.asp

 如果=东西和CINT(ID)&GT; 100则
    回复于(是这样花花公子)
其他
    的Response.Write(没有办法花花公子)
万一

作为它创建整个新的脚本环境的所执行的文件不能访问到调用code的属性,方法或变量,只有全局请求参数,会话等

考虑到这一点,我担心身边最简单的方法是使用会话变量传递页面之间的值:

 会议(ID)= 123
会议(A)=东西

和则:

 如果会议(A)=东西和Session(ID)&GT; 100则
    回复于(是这样花花公子)
其他
    的Response.Write(没有办法花花公子)
万一

It is possible to pass a parameter through server.execute?

Fx. I have in my site.asp an IF-scenario where I need functions.asp?a=something&id=123 executed. Is this possible?!

On site.asp:

dim id
id = 123

if b = "hi" then
  server.execute("functions.asp?a=something&id=" & id)
else
  response.write("No way dude")
end if

On functions.asp

a = request.querystring("a")
id = request.querystring("id")

if a = "something" and cint(id) > 100 then
  response.write("Yes way dude")
else
  response.write("No way dude")
end if

解决方案

You can't use querystring in Server.Execute, it's clearly mentioned in the official documentation.

What you can do is much better: you can directly access the variable id defined in site.asp inside functions.asp, and you can also declare and set another variable, a:

--site.asp:

dim id, a
id = 123
a = "something"
server.execute("functions.asp")

--functions.asp

if a = "something" and cint(id) > 100 then
    response.write("Yes way dude")
else  
    response.write("No way dude")
end if

As it creates whole new "scripting environment" the executed file won't have access to the calling code properties, methods or variables, only to the global Request parameters, Session etc.

With this in mind, I fear the most simple way around is using Session variable to pass the value between pages:

Session("id") = 123
Session("a") = "something"

And then:

if Session("a") = "something" and Session("id") > 100 then
    response.write("Yes way dude")
else  
    response.write("No way dude")
end if

这篇关于传递参数,通过使用Server.Execute?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆