how do you get current full aspx page name with querystring?

G

GaryDean

here's an example of my futzing around with a querystring....

you would use myValue1 instead of id. here, I was concatenating keys into one value and spliting them up.
If Not (Request.QueryString("id")) Is Nothing Then

Dim myString As String = Request.QueryString("id")

If Len(myString) = 7 Then 'we have both keys

'we should have a Customer record and at least one location record

Session("SelectedCustID") = myString.Substring(0, 4)

Session("LocID") = myString.Substring(5, 2)

Session("CustLocEditMode") = "MAINT"

Else

'customer exists but no location records exist - treat as new

'but put custID into textbox

Session("SelectedCustID") = myString.Substring(0, 4)

Session("LocID") = ""

Session("CustLocEditMode") = "NEW"

txtCustID.Text = Session("SelectedCustID")

End If


--
Regards,
Gary Blakely
Dean Blakely & Associates
www.deanblakely.com
If I have a url like this: www.somesite.com/mypage.aspx?myvalue1=hello&myvalue2=goodbye, in VB.NET, how do I get the "mypage.aspx?myvalue1=hello&myvalue2=goodbye" portion?

Thanks!
 
V

VB Programmer

Thanks for the example. I'm wondering if there's an out-of-the-box, simple function to simply return the whole string, where the querystrings may be unknown... Thanks...
here's an example of my futzing around with a querystring....

you would use myValue1 instead of id. here, I was concatenating keys into one value and spliting them up.
If Not (Request.QueryString("id")) Is Nothing Then

Dim myString As String = Request.QueryString("id")

If Len(myString) = 7 Then 'we have both keys

'we should have a Customer record and at least one location record

Session("SelectedCustID") = myString.Substring(0, 4)

Session("LocID") = myString.Substring(5, 2)

Session("CustLocEditMode") = "MAINT"

Else

'customer exists but no location records exist - treat as new

'but put custID into textbox

Session("SelectedCustID") = myString.Substring(0, 4)

Session("LocID") = ""

Session("CustLocEditMode") = "NEW"

txtCustID.Text = Session("SelectedCustID")

End If


--
Regards,
Gary Blakely
Dean Blakely & Associates
www.deanblakely.com
If I have a url like this: www.somesite.com/mypage.aspx?myvalue1=hello&myvalue2=goodbye, in VB.NET, how do I get the "mypage.aspx?myvalue1=hello&myvalue2=goodbye" portion?

Thanks!
 
J

Juan T. Llibre

There's no way to get it directly, but you can construct it very easily.

Dim name as string = System.IO.Path.GetFileName(Request.ServerVariables("SCRIPT_NAME"))
Dim qrystring as string = Request.ServerVariables("QUERY_STRING")
Dim fullname as string = name & "/" & qrystring

See it working at :

http://asp.net.do/test/querystring.aspx?myvalue1=hello&myvalue2=goodbye




If I have a url like this: www.somesite.com/mypage.aspx?myvalue1=hello&myvalue2=goodbye, in VB.NET,
how do I get the "mypage.aspx?myvalue1=hello&myvalue2=goodbye" portion?

Thanks!
 
V

VB Programmer

Thanks clintonG.

clintonG said:
For the most part writing splits and looping through arrays may not be
needed anymore. The point being there are other useful methods that parse
filenames, extensions and paths we often don't know about. Some others [1]
relevant to this context for example.

<%= Clinton

[1] http://aspnet.4guysfromrolla.com/articles/052505-1.aspx


Juan T. Llibre said:
They don't return what "VB Programmer" requested, Clinton.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top