Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

GetUrlParameters - Retrieving the key-value pairs from the specified url

Total Hit ( 2655)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 



Click here to copy the following block
' Returns a hashtable with the key-value pairs extracted from the querystring
' of the specified url

' EXAMPLE:
'  Dim ht As Hashtable = GetUrlParameters
' ("http://www.mysite.com?param1=123&param2=&param3=234")
'  ' print the key=value pairs to the console window
'  Dim myEnumerator As IDictionaryEnumerator = ht.GetEnumerator()
'  While myEnumerator.MoveNext()
'   Console.WriteLine("{0}: {1}", myEnumerator.Key, myEnumerator.Value)
'  End While
'  ' print the value of a specified param, named param3
'  Console.WriteLine("Param3: " & ht("param3"))

Function GetUrlParameters(ByVal url As String) As Hashtable
  Dim ht As New Hashtable()
  ' consider only the querystring, that's the part after the ? char
  Dim qsStart As Integer = url.IndexOf("?")
  If qsStart > -1 Then url = url.Substring(qsStart + 1)
  ' split the querystring with the & char
  Dim params() As String = url.Split(New Char() {"&"c})
  Dim param As String
  ' for each param extract the param name (the part before the =) and the
  ' value
  For Each param In params
    Dim i As Integer = param.IndexOf("="c)
    If i > -1 Then
      ht.Add(param.Substring(0, i), param.Substring(i + 1))
    End If
  Next
  Return ht
End Function


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.