Click here to Skip to main content
15,880,725 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My querystring has a "#" symbol in the middle of it. However, when I assign the querystring to another variable and it doesnt take the value after the "#" How can I get that value?


my url is :

C#
?RestaurantId=149?&Name=Siva?&LogoImageLocation=Images/Logos/vel_Siva_Pavoorchatram.jpg?&Description=Welcome to restaurant review guide on the web?&StreetAddress= #2West street,Delhi.


but wnen i assign this url in queryString am getting lik below:


C#
var queryString = new String();
 queryString = window.location.search;


in queryString ,am getting the below link
C#
?RestaurantId=149?&Name=Siva?&LogoImageLocation=Images/Logos/vel_Siva_Pavoorchatram.jpg?&Description=Welcome to restaurant review guide on the web?&StreetAddress= 



Street address is not display fully because of the "#" symbol ,Help me
Posted
Updated 23-Jan-12 1:13am
v3

Hi Priya
Quote:
Quote:



string valuue="your value"

HttpUtility.UrlEncode(value);

and pass that value with the querystring.
 
Share this answer
 
v2
Comments
priya from Madras 23-Jan-12 7:30am    
Thanks chandrashekhar,but am using this in javascript so can i use in this code in javasccript
First of all, you don't need to use ?& for the parameters. You start with ? and then add parameters using & like this: ?RestaurantId=149&Name=Siva

Second, # is an anchor. This part of the URL is used to jump (or scroll) to the anchor in the page. You can use the javascript function encodeURIComponent() to encode these characters. Check out the link for more info.
http://www.w3schools.com/jsref/jsref_encodeuricomponent.asp[^]

Good luck!
 
Share this answer
 
The Hash Sign (#) represents another portal of the URL (http://www.w3schools.com/jsref/prop_loc_hash.asp).
If you still need to include the # sign in query string and try the following code while retrieving the query string
window.location.search + window.location.hash


Or Try to use HTMLEncode/Decode

Happy Coding....
 
Share this answer
 
Comments
priya from Madras 23-Jan-12 7:54am    
Thanks Hariharasudhan,,Its working Fine
priya from Madras 23-Jan-12 9:26am    
Hi but its not working when the double code is used( "" )
priya from Madras 23-Jan-12 23:57pm    
Hi but its not working when the double quote is used( "" )
hariharasudhan chandramurthy 1-Feb-12 3:49am    
If you want the double code in your query string use backward slash (\) before the double code like
RestaurantId=149&Name=\"Siva\"&LogoImageLocation=Images/Logos/vel_Siva_Pavoorchatram.jpg&Description=Welcome to restaurant review guide on the web&StreetAddress= #2West street,Delhi.
Hi

var queryString = new String();
queryString = window.location.search + window.location.hash;


but its working for all character lik @,#,!,$,%,^,&,* but not in double Quote( "" )


Pls Help me
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900