I have multiple pages using a single VB code-behind. I want to pass 'pagename' to the codebehind so that I can then do different things for each page. However, I'm having trouble finding out how to do this.
Can anyone enlighten, in VB flavor?
Thanks,
Marshall
You don't have to set the name of the page, it already knows its own name: Request.FilePath will give you the current url, and the file name is the part after the last slash.
'Each page sets its name :
<script language="vb" runat="server">
Dim PageName As String = "BridgeLookup.aspx"
</script
'and I've been trying many things to pass it, including a hidden field
<inputtype="hidden" ID="PageName" NAME="PageName"
value="('<%=PageName%>')"
'what does the codebehind want?
Dim PageName = Request.Forms("PageName") ' doesn't work
Dim PageName = Request.Forms["PageName"] ' doesn't work'arg!
Please provide more info.
I tried adding the following to the code-behind file and to simply set a label to its value:
Dim PageName = Request.FilePathand got
Exception Details: System.Web.HttpException: Request is not available in this context
Source Error:
Line 61: Dim order_Bridges = "ORDER BY B.BridgeHostName "
Line 62:
Line 63: Dim PageName = Request.FilePath
Line 64:
Line 65: 'Init function'using Dim PageName as String
' PageName=Request.FilePath results in error "expression expected"
Thanks
In what event handler did you write the code?
You can access objects like the Request from any class using System.Web.HttpContext.Current.Request.
0 comments:
Post a Comment