/ Published in: VB.NET
Expand |
Embed | Plain Text
Public Function AddQuerystringVar(ByVal strURL As String, ByVal QuerystringKey As String, ByVal QuerystringValue As String) As String strURL = RemoveQuerystringVar(strURL, QuerystringKey) ' Remove value if already in URL If InStr(strURL, "?") = 0 Then Return strURL + "?" + QuerystringKey + "=" + QuerystringValue Else Return strURL + "&" + QuerystringKey + "=" + QuerystringValue End If End Function Public Function RemoveQuerystringVar(ByVal strURL As String, ByVal QuerystringKey As String) As String Dim re As New Regex("(.*)(\?|&)" + QuerystringKey + "=[^&]+?(&)(.*)", RegexOptions.IgnoreCase) strURL = re.Replace(strURL + "&", "$1$2$4") strURL = Mid(strURL, 1, (strURL.Length - 1)) Return strURL End Function
You need to login to post a comment.
