I have an aspx page that contains an iframe where I point to another aspx
page. In the aspx page that is in the iframe, I have VB code as follows:
<script language="vb" runat="server">
Dim strFolder As String = Request.QueryString("fldr").ToString
Dim PathVar As String = Server.MapPath("/wafgo/Pictures") & "\" & strFolder
& "\"
</script>
The Request.Querystring line is failing with the error Request is not
available in this context
I'm trying to pass the page a folder path and I don't know how else to do
it. I'm open to ideas. Thanks.
David
Teemu Keiski - 30 Oct 2007 20:59 GMT
Hi,
the code should be in any event of the Page. Like Init, Load or something.
Otherwise it gets executed "too early" during page lifecycle when certain
thuings aren't associated with the page, yet
Try
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
Dim strFolder As String = Request.QueryString("fldr").ToString
....
End Sub

Signature
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
>I have an aspx page that contains an iframe where I point to another aspx
>page. In the aspx page that is in the iframe, I have VB code as follows:
[quoted text clipped - 15 lines]
>
> David
David C - 30 Oct 2007 21:07 GMT
Should I have it in the called page or in the page referred to in the
iframe? Thanks.
David
> Hi,
>
[quoted text clipped - 30 lines]
>>
>> David
George Ter-Saakov - 30 Oct 2007 22:32 GMT
This code
Dim strFolder As String = Request.QueryString("fldr").ToString
is executed during construction phase.
ASP.NET page did not get a chance to assign Request to the page.
George.
>I have an aspx page that contains an iframe where I point to another aspx
>page. In the aspx page that is in the iframe, I have VB code as follows:
[quoted text clipped - 15 lines]
>
> David
bruce barker - 30 Oct 2007 22:37 GMT
request is a Page property, which can not be accessed by a class field
initialization expression, because the constructor has not been called.
class foo
dim strFolder as string = myProperty
...
try:
Dim strFolder As String =
HttpContext.Current.Request.QueryString("fldr").ToString
-- bruce (sqlwork.com)
> I have an aspx page that contains an iframe where I point to another aspx
> page. In the aspx page that is in the iframe, I have VB code as follows:
[quoted text clipped - 15 lines]
>
> David