Join Request.Form and Request.Querystring
Skip Navigation Links.

Join Request.Form and Request.Querystring

Skip Navigation LinksHome :: Classic ASP :: Join Request.Form to Querystring

Here's a Vb function you can use on active server pages to return a new querystring from the mixture of Request.Form and Request.Querystring. It will ensure unique arguments are returned. This is particularly useful in paging strings where you propagate values using hidden form fields. Search engines don't index form fields so use FillQstring to produce URL's they can follow e.g. when you use a client side cursor for pages 1,2,3 etc. example here

Call like this: Request.Form = "text1=x&text2=y" Request.Querystring = "?x=1&h=2"
Returns this: ?x=1&h=2text1=x&text2=y
Also requires: DeleteToken()

here's a test page

<%
Function FillQstring()
'return a querystring from the mixture of Request.Form and Request.Querystring
'ensure unique arguments are returned
'the form must always 'win' if there is the same item in both
    Dim intI, MyArray, strForm, strQS
        strForm = Request.Form
        'Compare Request.QueryString to strForm so no duplicate items
        MyArray = Split(Request.QueryString,"&")
        For IntI = LBound(MyArray) To UBound(MyArray)
            strForm = DeleteToken (strForm,MyArray(IntI),"&","=")
        Next 'IntI
    strQS = Request.QueryString
    strQS = strQS & strForm 'join 'em up
    'make sure the querystring is well formed
    If Right (strQS,1) = "&" Then strQS = Left(strQS,Len(strQS)-1)
    If strQS = "" Then strQS = "?new=x" & strQS
    If Left (strQS,1) = "&" Then strQS = Right(strQS,Len(strQS)-1)
    If Left (strQS,1) <> "?" Then strQS = "?" & strQS
    FillQstring = strQS
End Function
%>

cut and paste the Visual Basic code below onto an Active Server Page

Next >> SQL Server
top of page
all content ©1996/2012 BennySutton.com
all images © their respective owners This site uses Thumbshots previews