公共可变QueryString问题 [英] Public varaible QueryString issue

查看:64
本文介绍了公共可变QueryString问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计,


一个aspx页面在URL中有一些查询字符串变量。


在代码beind文件中,我试过请求这些变量和设置

作为公共变量,因此它不是特定于子。


公共instance_id As Decimal = Request.QueryString(" i_id")


这个定义如上:Private Sub Page_Load


它不起作用 - 缺少什么?


谢谢。


***通过Developersdex发送 http://www.developersdex.com ***

解决方案

是错误还是根本没有设置值?

" VK"写道:

人们,

一个aspx页面在URL中有一些查询字符串变量。

在代码beind文件中,我尝试请求这些变量并将
设置为公共变量,因此它不是特定于子。

Public instance_id As Decimal = Request.QueryString(" i_id")

这在上面定义:Private Sub Page_Load

它不起作用 - 缺少什么?

谢谢。

***通过开发人员指南 http://www.developersdex.com 发送***



为什么不在Load或Init事件中设置变量?


" VK" < vk@vk.com>在消息中写道

新闻:OG ************** @ tk2msftngp13.phx.gbl ...

人们,
一个aspx页面在URL中有一些查询字符串变量。

在代码beind文件中,我尝试请求这些变量并将
设置为公共变量,因此它不具体公共instance_id作为Decimal = Request.QueryString(" i_id")

这是在上面定义的:Private Sub Page_Load

>它不起作用 - 缺少什么?

谢谢。

***通过Developersdex发送 http://www.developersdex.com ***



错误消息:

请求在此上下文中不可用

描述:在执行

当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取更多信息

有关错误及其在代码中的起源。


异常详细信息:System.Web.HttpException:Request is is不适用

这个上下文


来源错误:

第40行:公共myConn As SqlConnection = New

SqlConnection(ConfigurationSettings.AppSettings(O nlineToolkitv2))

第41行:Public tool_id As Decimal = 1

第42行:Public instance_id As Integer = Request .QueryString(" i_id")

第43行:公共number_of_questions为整数


- 我无法在Load中使用它,因为它无法使用在其他sub或

函数中,其范围仅存在于Load中。


谢谢。


* **通过开发人员指南 http://www.developersdex.com 发送***

Folks,

An aspx page has some querystring variables in the URL.

In the code beind file, I tried requesting these variables and setting
as public variables, so it is not specific to a sub.

Public instance_id As Decimal = Request.QueryString("i_id")

This is defined right above:Private Sub Page_Load

It doesn''t work - is something missing??

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***

解决方案

Does it error or simply not set the value?
"VK" wrote:

Folks,

An aspx page has some querystring variables in the URL.

In the code beind file, I tried requesting these variables and setting
as public variables, so it is not specific to a sub.

Public instance_id As Decimal = Request.QueryString("i_id")

This is defined right above:Private Sub Page_Load

It doesn''t work - is something missing??

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***



Why not set the variable in the Load or Init events?

"VK" <vk@vk.com> wrote in message
news:OG**************@tk2msftngp13.phx.gbl...

Folks,

An aspx page has some querystring variables in the URL.

In the code beind file, I tried requesting these variables and setting
as public variables, so it is not specific to a sub.

Public instance_id As Decimal = Request.QueryString("i_id")

This is defined right above:Private Sub Page_Load

It doesn''t work - is something missing??

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***



The error message:
Request is not available in this context
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Request is not available in
this context

Source Error:
Line 40: Public myConn As SqlConnection = New
SqlConnection(ConfigurationSettings.AppSettings("O nlineToolkitv2"))
Line 41: Public tool_id As Decimal = 1
Line 42: Public instance_id As Integer = Request.QueryString("i_id")
Line 43: Public number_of_questions As Integer

- I can''t use it in Load since it cannot be used in other subs or
functions, its scope would exist with in Load only.

thanks.

*** Sent via Developersdex http://www.developersdex.com ***


这篇关于公共可变QueryString问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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