R
rn5a
I want to use the Request object within the <script> tag but outside
any subs/functions in an ASPX page...something like this (so that I can
use the variable strUserName in any other subs/functions so as to avoid
re-declaring it & re-assigning a value to it in every sub/function
within this page):
<%@ Import Namespace="System.Web.HttpRequest" %>
<script runat="server">
Public strUserName As String = Request.Cookies("UserName").Value
Sub Page_Load(.......)
lblUserName.Text = strUserName
blah....blah....blah......
End Sub
</script>
But I get the error
Request is not available in this context.
pointing to the first line within the <script> tag.
How do I make use of Request under such s scenario?
any subs/functions in an ASPX page...something like this (so that I can
use the variable strUserName in any other subs/functions so as to avoid
re-declaring it & re-assigning a value to it in every sub/function
within this page):
<%@ Import Namespace="System.Web.HttpRequest" %>
<script runat="server">
Public strUserName As String = Request.Cookies("UserName").Value
Sub Page_Load(.......)
lblUserName.Text = strUserName
blah....blah....blah......
End Sub
</script>
But I get the error
Request is not available in this context.
pointing to the first line within the <script> tag.
How do I make use of Request under such s scenario?