Click here to Skip to main content
15,867,777 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi i am new to asp.net technology

i need small information, iam using the "Filesystem" as my host in C#.net webapplication,

here my problem is i am Navigating the url to "www.google.com" throught the Hyperlink but i was taking as something more like


"http://localhost:1162/Secure%20Distributed%20Systems/www.google.com"

my sample code is


HyperLink1.NavigateUrl ="www.google.com";

and also iam trying like
hyperlink==>
properties==>
Navigatingurl="WWW.google.com"

iam trying both the types , what is the problem, how to avoid this one
Posted
Updated 21-Nov-22 3:47am
Comments
Member 9641223 30-Nov-12 1:03am    
i wnt to close a window by using log out image button

Try this

<asp:HyperLink ID="MyHyperLinkControl" NavigateUrl="http://google.com" runat="server">link</asp:HyperLink>
 
Share this answer
 
v3
Comments
[no name] 28-May-11 4:55am    
yes it was working but i am trying as www.google.com was not working , what is the reason behind it
explain please
demouser743 28-May-11 5:14am    
I'm guessing its because it treats the URL as a relative one and so if you're currently on page: www.yourdomain.com/ the second will try and navigate to www.yourdomain.com/www.google.com. However if you put the http in front you are telling the link that it should be an absolute link

WWW is not a keyword meaning this is an external webpage - its essentially a convention.
[no name] 30-May-11 5:55am    
thanks alot for the reasoning
Your ASP.NET hyperlink code will be translated to:
HTML
<a href="www.google.com">link</a>

If any link is not prefex with the symbol slash "/" or a scheme "https/http", the browser will append your provided link with current web folder path.

Example, this:
HTML
www.google.com

will become this:
HTML
http://www.yourwebsite.com/www.google.com

or this:
HTML
http://www.yourwebsite.com/member/www.google.com

It has nothing to with the Hyperlink server control in ASP.NET. It is the default behaviour of HTML.

Therefore, your have to prefix it with the scheme:
HTML
https

like this:
ASP.NET
<asp:HyperLink ID="hp1" runat="server" NavigateUrl="https://www.google.com">Link</asp:HyperLink>
 
Share this answer
 
v4
use
this
it will definitely work

hyperlink1.NavigateUrl="http://www.google.com"  
 
Share this answer
 

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