Search EggHeadCafe's Job Board
EggHeadCafe Silverlight WPF ASP.NET VB.NET C# Excel SQL Server SharePoint
search
MicrosoftArticlesForumsFAQs
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml / Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

WebArticlesForumsFAQs
JavaScript
ASP
ASP.NET
WCF

DatabasesArticlesForumsFAQs
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsFAQs
Excel
Word
Powerpoint
Outlook
Publisher
Money

Non-MicrosoftArticlesForumsFAQs
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

Operating SysArticlesForumsFAQs
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsFAQs
BizTalk
Site Server
Exhange Server
IIS

Graphic DesignArticlesForumsFAQs
Macromedia Flash
Adobe PhotoShop
Expression Blend
Expression Design
Expression Web

OtherArticlesForumsFAQs
Lounge
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Product Reviews
Search Engines
Resumes

 

  View Other ASP Posts   Ask New Question  Ask New Question With Power Editor

URL query
Randy Inaneway posted at Tuesday, November 03, 2009 1:06 PM

I think I was able to query 2 values from 1 field but I can't remember how.

Example: field contains values 1, 2 , 3 for different records. I want to return 1 & 2 somthing like this:

pagename.asp?SWITCH=1

pagename.asp?SWITCH=2

that works fine but I want to return 1 AND 2

 

pagename.asp?SWITCH=1&2 does not work. It seems I did somthing like SWITCH=[1][2] or something similar some time ago and it worked but I just can't recall.

Is this possible or am I dreaming?

Thank you very much

 

 

 

 

 

 

Reply    Reply Using Power Editor
  Rank Winnings Points
November 0 $0.00 0
October 0 $0.00 0
re
Web star provided a rated reply to Randy Inaneway on Tuesday, November 03, 2009 11:00 PM

in URL passing querystring '&' use for seprate two different variables in url so u don't use 1&2

so u can wnat to get two value passing in query string then try this way

pagename.asp?SWITCH=1,2

and then u will split on comma(,) and get 1 and 2

or u can use this

 pass two value then use two different variable as follows

pagename.asp?SWITCH=1&SWITCH2=2

Reply    Reply Using Power Editor
  Rank Winnings Points
November 5 $55.00 143
October 10 $28.00 94

Couple of ways.
[)ia6l0 iii provided a rated reply to Randy Inaneway on Wednesday, November 04, 2009 12:31 AM

You would use the same variable name with your multi-values and create the url. However, a note of caution that there is a length limit to the querystring. Instead you would ideally use other ways of communicating between two asp web pages.

And also note that the Ampersand ("&") is used to separates parameters and not to concatenate them.

You can also give the values as comma separated and then use the indices to retrieve each one of them. But again, this is not adviced as it involved code change in the dependant file once the query string changes in your calling code.

If the param in the Querystring is called "myParam" and has the value "a, b, c"; to retrieve all of them you would write,
Response.Write Request.QueryString("myParam")
And to retrieve each one of them you would do ,
Response.Write Request.QueryString("myParam")(1) ' would give a
Response.Write Request.QueryString("myParam")(2) ' would give b
Response.Write Request.QueryString("myParam")(3)
' would give c

also not that in ASP, you could give the same name to the request querystring variables and still retrieve values.
Like the following example.
http://localhost/webfolder/page1.asp?param1=a&param1=b&param1=c

Response.Write Request.QueryString("param1")(1) ' would give a
Response.Write Request.QueryString("param1")(2)' would give b
Response.Write Request.QueryString("param1")(3)' would give c

Reply    Reply Using Power Editor
  Rank Winnings Points
November 1 $217.00 560
October 1 $226.00 771

asp
Jack jack replied to Randy Inaneway on Monday, November 09, 2009 2:09 AM

http://localhost/Website/page1.asp?n=1&n=2&n=3

for i=1 to Request.QueryString("n").Count
  Response.Write(Request.QueryString("n")(i) & "<br />")
next

It Will GIve
1
2
3

Reply    Reply Using Power Editor
  Rank Winnings Points
November 16 $0.00 19
October 0 $0.00 0