Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
1.44/5 (3 votes)
See more:
C#
Response.Write("<script>window.open('http://www.micro'soft.com','_blank');</script>");


Error because of apostrophe.

I got a website which has apostrophe in the middle like this www.micro'soft.com

because of this apostrophe the website is not loading properly
Posted
Comments
Sergey Alexandrovich Kryukov 11-Dec-13 10:53am    
You got? Are you serious? How did you "get" it? :-)
—SA
sathish kumar 11-Dec-13 10:58am    
intranet
Karthik_Mahalingam 11-Dec-13 11:03am    
did my solution works for you ?
Sergey Alexandrovich Kryukov 11-Dec-13 11:06am    
It does not answer my question. I'm extremely puzzled.
—SA

Apostrophe's are not valid in domain names, they can be encoded in the URL part, but they are not allowed in the root domain.

Are you sure its not in the URL instead of the root domain?
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 11-Dec-13 10:52am    
5ed. What is that, new nickname, "Micro'soft"? Or "delicate" and "cryptic" method of phishing? :-)
—SA
Ron Beyer 11-Dec-13 10:54am    
I don't understand it either, thanks Sergey.
sathish kumar 11-Dec-13 10:58am    
intranet
Karthik_Mahalingam 11-Dec-13 11:01am    
I got a website which has apostrophe in the middle like this www.micro'soft.com
its just an example...

read the post clearly...
Ron Beyer 11-Dec-13 11:05am    
I did read the post clearly, and if you read the ICANA guidelines clearly, it states that apostrophe's are not allowed in root level domain names.
Use backslash to escape special characters in JavaScript strings, e.g.

Response.Write(@"<script>window.open('http://www.domain.com/url-with-\'quote','_blank');</script>");


Note that I've also changed the C# string to be a @ string so you don't have to escape the backslash and the quote in the C# code.

I've also changed the URL to a realistic example because as people above have said, a URL with a quote in the domain part is not valid and won't work even if you format the code correctly.
 
Share this answer
 
Hi



use &apos; instead of '


C#
Response.Write("<script>window.open('http://www.micro'soft.com','_blank');</script>");


reference : http://technet.microsoft.com/en-us/library/aa226544(v=sql.80).aspx[^]
 
Share this answer
 
v3
Comments
sathish kumar 11-Dec-13 11:05am    
XML Parsing Error: no element found

It takes the url also like this
http://www.micro'soft.com
Karthik_Mahalingam 11-Dec-13 11:08am    
ur question is this only know ??
sathish kumar 11-Dec-13 11:12am    
oops sorry this code editor convert my ' automatically into '.

actually it's taking me to http://www.micro& apos ;soft.com .. fyi - ignore the space
Karthik_Mahalingam 11-Dec-13 11:15am    
can u send me ur code ?
latest, updated code..
sathish kumar 11-Dec-13 11:19am    
the code is exactly the same one which is in the solution 2 above

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