Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Removing a Querystring Name & Value

Reply
Thread Tools

Removing a Querystring Name & Value

 
 
scott
Guest
Posts: n/a
 
      07-29-2005
Below, I'm trying to remove the querystring name& value of "catID=12".
I mananged to isolate the RESULTS part, but I need to be able to strip the
querystring name and it's value, no matter if the value is 1, 2 or 3 digits.
I chose to isolate the part I'd be removing below because I know I can take
it
and run a replace and get correct string, although I hardcoded the qs name.

Basically, I'd like to end up with a function that I could just pass the
name of the querystring and the function would remove the qs name and it's
value.

One other issue, if the querystring name and value are the only part of the
querystring, I need to delete the "?" within the qs.

Any help?

CODE:

sQueryString = "millID=2&catID=12"

iMarker = InStr(sQueryString ,"catID")
mystring= Right(sQueryString ,Len(sQueryString )-iMarker+1)


RESULTS:
mystring=catID=1





 
Reply With Quote
 
 
 
 
Chris Hohmann
Guest
Posts: n/a
 
      07-29-2005
"scott" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Below, I'm trying to remove the querystring name& value of "catID=12".
> I mananged to isolate the RESULTS part, but I need to be able to strip the
> querystring name and it's value, no matter if the value is 1, 2 or 3
> digits.
> I chose to isolate the part I'd be removing below because I know I can
> take it
> and run a replace and get correct string, although I hardcoded the qs
> name.
>
> Basically, I'd like to end up with a function that I could just pass the
> name of the querystring and the function would remove the qs name and it's
> value.
>
> One other issue, if the querystring name and value are the only part of
> the
> querystring, I need to delete the "?" within the qs.
>
> Any help?


<%
Function Remove_QS_Parameter(qs, p)
Dim retVal, re
Set re = New RegExp
re.Pattern = "(\?|&)" & p & "=.*?(&|$)"
retVal = re.Replace(qs,"$2")
If Left(retVal,1) = "&" Then retVal = "?" & Mid(retVal,2)
Remove_QS_Parameter = retVal
End Function

CONST qs = "?param1=1&param2=02&param3=003"
Response.Write Remove_QS_Parameter(qs,"param1") & "<br>"
Response.Write Remove_QS_Parameter(qs,"param2") & "<br>"
Response.Write Remove_QS_Parameter(qs,"param3") & "<br>"
%>


 
Reply With Quote
 
 
 
 
scott
Guest
Posts: n/a
 
      07-29-2005
here's results below: why the paragraph mark? also results are close, but
not right. can you correct, i can't fix your code.


qs: ?param1=1śm2=02śm3=003

results:
?param2=02śm3=003
?param1=1śm3=003
?param1=1śm2=02




"Chris Hohmann" <(E-Mail Removed)> wrote in message
news:u$(E-Mail Removed)...
> "scott" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Below, I'm trying to remove the querystring name& value of "catID=12".
>> I mananged to isolate the RESULTS part, but I need to be able to strip
>> the
>> querystring name and it's value, no matter if the value is 1, 2 or 3
>> digits.
>> I chose to isolate the part I'd be removing below because I know I can
>> take it
>> and run a replace and get correct string, although I hardcoded the qs
>> name.
>>
>> Basically, I'd like to end up with a function that I could just pass the
>> name of the querystring and the function would remove the qs name and
>> it's
>> value.
>>
>> One other issue, if the querystring name and value are the only part of
>> the
>> querystring, I need to delete the "?" within the qs.
>>
>> Any help?

>
> <%
> Function Remove_QS_Parameter(qs, p)
> Dim retVal, re
> Set re = New RegExp
> re.Pattern = "(\?|&)" & p & "=.*?(&|$)"
> retVal = re.Replace(qs,"$2")
> If Left(retVal,1) = "&" Then retVal = "?" & Mid(retVal,2)
> Remove_QS_Parameter = retVal
> End Function
>
> CONST qs = "?param1=1&param2=02&param3=003"
> Response.Write Remove_QS_Parameter(qs,"param1") & "<br>"
> Response.Write Remove_QS_Parameter(qs,"param2") & "<br>"
> Response.Write Remove_QS_Parameter(qs,"param3") & "<br>"
> %>
>



 
Reply With Quote
 
scott
Guest
Posts: n/a
 
      07-29-2005
my browser is showing paragraph marks where ampersand marks should be, and
formula is wrong.


"Chris Hohmann" <(E-Mail Removed)> wrote in message
news:u$(E-Mail Removed)...
> "scott" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Below, I'm trying to remove the querystring name& value of "catID=12".
>> I mananged to isolate the RESULTS part, but I need to be able to strip
>> the
>> querystring name and it's value, no matter if the value is 1, 2 or 3
>> digits.
>> I chose to isolate the part I'd be removing below because I know I can
>> take it
>> and run a replace and get correct string, although I hardcoded the qs
>> name.
>>
>> Basically, I'd like to end up with a function that I could just pass the
>> name of the querystring and the function would remove the qs name and
>> it's
>> value.
>>
>> One other issue, if the querystring name and value are the only part of
>> the
>> querystring, I need to delete the "?" within the qs.
>>
>> Any help?

>
> <%
> Function Remove_QS_Parameter(qs, p)
> Dim retVal, re
> Set re = New RegExp
> re.Pattern = "(\?|&)" & p & "=.*?(&|$)"
> retVal = re.Replace(qs,"$2")
> If Left(retVal,1) = "&" Then retVal = "?" & Mid(retVal,2)
> Remove_QS_Parameter = retVal
> End Function
>
> CONST qs = "?param1=1&param2=02&param3=003"
> Response.Write Remove_QS_Parameter(qs,"param1") & "<br>"
> Response.Write Remove_QS_Parameter(qs,"param2") & "<br>"
> Response.Write Remove_QS_Parameter(qs,"param3") & "<br>"
> %>
>



 
Reply With Quote
 
Chris Hohmann
Guest
Posts: n/a
 
      07-29-2005
"scott" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> here's results below: why the paragraph mark? also results are close, but
> not right. can you correct, i can't fix your code.
>
>
> qs: ?param1=1śm2=02śm3=003
>
> results:
> ?param2=02śm3=003
> ?param1=1śm3=003
> ?param1=1śm2=02


My code is fine. However, you may be cutting and pasting in a non-standard
way such that the paste operation is interpreting the occurrences of "&para"
as the paragraph entity character. Try the following:

1. Open Outlook Express and highlight the code I provided
2. Hit CTRL+C to copy the text into the copy/paste buffer
3. Open Notepad
4. Hit CTRL+V to paste the copied text into the Notepad window.
5. Hit CTRL+S to save the file. Save the file with a ".asp" extension and
place it somewhere in your web directory
6. Open Internet Explorer and navigate to the newly saved file.
7. Report back on whether or not this solves your problem.


 
Reply With Quote
 
scott
Guest
Posts: n/a
 
      07-29-2005
this is results after changing the qs name, your previous code rendered
paragraph marks. see the problem?

i'm a quadraplegic, i'm in a hospital, can you help me fix a function as
described before? it's really hard for me to type.

?myparam2=02&myparam3=003
?myparam1=1&myparam3=003
?myparam1=1&myparam2=02



"Chris Hohmann" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "scott" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> here's results below: why the paragraph mark? also results are close, but
>> not right. can you correct, i can't fix your code.
>>
>>
>> qs: ?param1=1śm2=02śm3=003
>>
>> results:
>> ?param2=02śm3=003
>> ?param1=1śm3=003
>> ?param1=1śm2=02

>
> My code is fine. However, you may be cutting and pasting in a non-standard
> way such that the paste operation is interpreting the occurrences of
> "&para" as the paragraph entity character. Try the following:
>
> 1. Open Outlook Express and highlight the code I provided
> 2. Hit CTRL+C to copy the text into the copy/paste buffer
> 3. Open Notepad
> 4. Hit CTRL+V to paste the copied text into the Notepad window.
> 5. Hit CTRL+S to save the file. Save the file with a ".asp" extension and
> place it somewhere in your web directory
> 6. Open Internet Explorer and navigate to the newly saved file.
> 7. Report back on whether or not this solves your problem.
>



 
Reply With Quote
 
Chris Hohmann
Guest
Posts: n/a
 
      07-29-2005
"scott" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> this is results after changing the qs name, your previous code rendered
> paragraph marks. see the problem?
>
> i'm a quadraplegic, i'm in a hospital, can you help me fix a function as
> described before? it's really hard for me to type.
>
> ?myparam2=02&myparam3=003
> ?myparam1=1&myparam3=003
> ?myparam1=1&myparam2=02


I'm sorry to here about your condition. I can empathize as I am also
disabled and have spent considerable time hospitalized. Would it be possible
for you to show my previous reply to a nurse, aide or a computer savvy
visitor? Cutting and pasting the code I provided should be a simple
procedure for anyone who has even a small bit of experience with computers.
I would also strongly recommend that you speak with an occupational
therapist about getting adaptive technologies to facilitate the use of
computers.


 
Reply With Quote
 
scott
Guest
Posts: n/a
 
      07-29-2005
i pasted ascii text chris. it's listed below. i'm a c5/c6 quad, just asking
for a little professional courtesy. if you can't fix your code, thanks
anyway.

i'll repost.



your code:


<%
Function Remove_QS_Parameter(qs, p)
Dim retVal, re
Set re = New RegExp
re.Pattern = "(\?|&)" & p & "=.*?(&|$)"
retVal = re.Replace(qs,"$2")
If Left(retVal,1) = "&" Then retVal = "?" & Mid(retVal,2)
Remove_QS_Parameter = retVal
End Function

CONST qs = "?myparam1=1&myparam2=02&myparam3=003"

Response.Write Remove_QS_Parameter(qs,"myparam1") & "<br>"
Response.Write Remove_QS_Parameter(qs,"myparam2") & "<br>"
Response.Write Remove_QS_Parameter(qs,"myparam3") & "<br>"
%>


YOUR RESULTS;


?myparam2=02&myparam3=003
?myparam1=1&myparam3=003
?myparam1=1&myparam2=02








"Chris Hohmann" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "scott" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> this is results after changing the qs name, your previous code rendered
>> paragraph marks. see the problem?
>>
>> i'm a quadraplegic, i'm in a hospital, can you help me fix a function as
>> described before? it's really hard for me to type.
>>
>> ?myparam2=02&myparam3=003
>> ?myparam1=1&myparam3=003
>> ?myparam1=1&myparam2=02

>
> I'm sorry to here about your condition. I can empathize as I am also
> disabled and have spent considerable time hospitalized. Would it be
> possible for you to show my previous reply to a nurse, aide or a computer
> savvy visitor? Cutting and pasting the code I provided should be a simple
> procedure for anyone who has even a small bit of experience with
> computers. I would also strongly recommend that you speak with an
> occupational therapist about getting adaptive technologies to facilitate
> the use of computers.
>



 
Reply With Quote
 
Chris Hohmann
Guest
Posts: n/a
 
      07-30-2005
"scott" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>i pasted ascii text chris. it's listed below. i'm a c5/c6 quad, just asking
>for a little professional courtesy. if you can't fix your code, thanks
>anyway.
>
> i'll repost.
>
>
>
> your code:
>
>
> <%
> Function Remove_QS_Parameter(qs, p)
> Dim retVal, re
> Set re = New RegExp
> re.Pattern = "(\?|&)" & p & "=.*?(&|$)"
> retVal = re.Replace(qs,"$2")
> If Left(retVal,1) = "&" Then retVal = "?" & Mid(retVal,2)
> Remove_QS_Parameter = retVal
> End Function
>
> CONST qs = "?myparam1=1&myparam2=02&myparam3=003"
>
> Response.Write Remove_QS_Parameter(qs,"myparam1") & "<br>"
> Response.Write Remove_QS_Parameter(qs,"myparam2") & "<br>"
> Response.Write Remove_QS_Parameter(qs,"myparam3") & "<br>"
> %>
>
>
> YOUR RESULTS;
>
>
> ?myparam2=02&myparam3=003
> ?myparam1=1&myparam3=003
> ?myparam1=1&myparam2=02


Sigh. I'd be happy to "fix" my code. Just tell me what's wrong with it.
Otherwise, you probably are better off reposting, since I am obviously
missing something. Good luck.


 
Reply With Quote
 
scott
Guest
Posts: n/a
 
      07-30-2005
no, it is i who have missed something, i deeply apologize for temporary
stupidity. the medication is affecting my brain more than i thought.


"Chris Hohmann" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> "scott" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>>i pasted ascii text chris. it's listed below. i'm a c5/c6 quad, just
>>asking for a little professional courtesy. if you can't fix your code,
>>thanks anyway.
>>
>> i'll repost.
>>
>>
>>
>> your code:
>>
>>
>> <%
>> Function Remove_QS_Parameter(qs, p)
>> Dim retVal, re
>> Set re = New RegExp
>> re.Pattern = "(\?|&)" & p & "=.*?(&|$)"
>> retVal = re.Replace(qs,"$2")
>> If Left(retVal,1) = "&" Then retVal = "?" & Mid(retVal,2)
>> Remove_QS_Parameter = retVal
>> End Function
>>
>> CONST qs = "?myparam1=1&myparam2=02&myparam3=003"
>>
>> Response.Write Remove_QS_Parameter(qs,"myparam1") & "<br>"
>> Response.Write Remove_QS_Parameter(qs,"myparam2") & "<br>"
>> Response.Write Remove_QS_Parameter(qs,"myparam3") & "<br>"
>> %>
>>
>>
>> YOUR RESULTS;
>>
>>
>> ?myparam2=02&myparam3=003
>> ?myparam1=1&myparam3=003
>> ?myparam1=1&myparam2=02

>
> Sigh. I'd be happy to "fix" my code. Just tell me what's wrong with it.
> Otherwise, you probably are better off reposting, since I am obviously
> missing something. Good luck.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get value of QueryString inside QueryString Mehdi ASP .Net 6 04-06-2006 03:41 PM
Passing QueryString URL as a paremeter in QueryString Adeel Ahmad ASP General 1 03-07-2006 02:05 PM
Removing a Querystring Name & Value scott ASP General 0 07-28-2005 08:47 PM
Clearing QueryString Name/Value pair from URL Jon ASP .Net 3 02-09-2004 10:30 PM
Request.Form("Field Name") Versus Request.QueryString("Field Name") John Davis ASP General 2 08-18-2003 05:00 AM



Advertisments