C# HELP
C# HELP
I have a problem that I need to solve right away and I'm in desperate need for help. Can anyone tell me how to parse a query using a page.clientquerystring?
I don't know much about ASP.NET but I would assume you firstly split it into an array of strings using .Split('&') and then split each element further with .Split('=')
The second split should give you an array of length 2. The first element will be the parameter name and the second will be it's value. You can send the parameter name through a switch statement.
There's probably an easier way to do this...
The second split should give you an array of length 2. The first element will be the parameter name and the second will be it's value. You can send the parameter name through a switch statement.
There's probably an easier way to do this...
DFI LanParty X48 LT-2TR
Intel Q9450 @ 3.2Ghz
Dell 24" 2408WFP | Phillips 37" 1080p
Sapphire HD4870 X2 2GB
4GB Corsair DDR-2 1066 | Thermalrite 120 Ultra Extreme | G9 Mouse | G15 Keyboard
Vista Ultimate x64
Intel Q9450 @ 3.2Ghz
Dell 24" 2408WFP | Phillips 37" 1080p
Sapphire HD4870 X2 2GB
4GB Corsair DDR-2 1066 | Thermalrite 120 Ultra Extreme | G9 Mouse | G15 Keyboard
Vista Ultimate x64
- Ron2K
- Forum Technical Administrator
- Posts: 9050
- Joined: 04 Jul 2006, 16:45
- Location: Upper Hutt, New Zealand
- Contact:
There is indeed an easier way.
Let's look at a URL like this: http://www.pcformat.co.za/modules.php?n ... ic&t=26378
You would then call the following code to get the values in the query:
Request.QueryString["name"]
Request.QueryString["file"]
Request.QueryString["t"]
In the URL I provided earlier, they would return "Forums", "viewtopic" and "26378" respectively
Strings are returned; if you want other data types returned, you'll have to manually convert.
If you request something that isn't there (in the URL above, something like Request.QueryString["warble"]), null is returned.
Hope this helps.
Let's look at a URL like this: http://www.pcformat.co.za/modules.php?n ... ic&t=26378
You would then call the following code to get the values in the query:
Request.QueryString["name"]
Request.QueryString["file"]
Request.QueryString["t"]
In the URL I provided earlier, they would return "Forums", "viewtopic" and "26378" respectively
Strings are returned; if you want other data types returned, you'll have to manually convert.
If you request something that isn't there (in the URL above, something like Request.QueryString["warble"]), null is returned.
Hope this helps.
Kia kaha, Kia māia, Kia manawanui.