views:

26

answers:

1

I'd like to implement a hyperlink in many locations on my website, however I just want to have it defined once not several times over. What is the best way to achieve this?

I started down the road of listing it in the node of web.config but I was only able to get that to list as a literal and wasn't successful in having it end up as a hyperlink.

I don't know much about master pages, but what I do know about them seems to me that they aren't the answer for this task because they wouldn't allow for that hyperlink to be located on some pages and not others and in different locations on some pages than others.

Help please! :)

I'm working in ASP.net VB.net

A: 

Put a HyperLink control on each page where you want it.

e.g. <asp:HyperLink runat="server" id="LogInLink">Login</asp:HyperLink>

Then either set the NavigateUrl property on the hyperlink in code-behind, e.g. this.LogInLink.NavigateUrl = Global.MySpecialUrl; or use <%=Global.MySpecialUrl%> notation to reference the value you want from your code in the NavigateUrl in the markup.

[Sorry, that's C# code]

Hightechrider
Ok, I was hoping that there would be a way to do with without code behind. But, that looks understandable... How about the text related to the hyperlink, how would you declare that only in one place as well?
Dactyl
Well you *can* set that in code behind too, or use the <%= technique, or your could look into using resource files e.g. http://msdn.microsoft.com/en-us/library/fw69ke6f(VS.80).aspx
Hightechrider
What would the <%= technique look like for something like this? Btw, thank you for your help.
Dactyl