Hi,
I'm more of an html programer who is trying to leverage asp.net to make my html programing easier and smarter, so I don't fully understand the .net paradigm yet. I have a design question, and I would like some opinions on it.
Let me try and set the situation. I have a nav on the left side of my website, and it is the same for all pages, so I have it in an include file(user control) leftNav.ascx. This control consists of various anchor tags leading to pages within the web site.
My goal is to have the anchor tag of the page you are on a different color from all the other tags. This is not so hard to do, but it is difficult for me to do it right.
I do it like this:
This control accepts a paramater pageName, and you pass the name of the page in a string, like so
Then each of the links has an inline function:
and the function:
Not too complicated, but you can see the inherant problem, too much hard coding of strings. If I want to change the name of the page, I have then change the param I pass to my control, and then the param I pass to my inline function.
I thought of passing ordinals, like 1 or 2 to the control, but I would like something more descriptive. I have many pages, and remembering that "cleaningTips.aspx" is page 10 is a pain, and what if I change the order?
Any tips/comments/suggestions are much appriciated.
Can I throw one more requirement? I don't want my control based on a form. I don't want to use <asp:a > although that might make my life simpler, because then my page will not validate, which is a project requirement.
Thanks again
CJB
I'm more of an html programer who is trying to leverage asp.net to make my html programing easier and smarter, so I don't fully understand the .net paradigm yet. I have a design question, and I would like some opinions on it.
Let me try and set the situation. I have a nav on the left side of my website, and it is the same for all pages, so I have it in an include file(user control) leftNav.ascx. This control consists of various anchor tags leading to pages within the web site.
My goal is to have the anchor tag of the page you are on a different color from all the other tags. This is not so hard to do, but it is difficult for me to do it right.
I do it like this:
This control accepts a paramater pageName, and you pass the name of the page in a string, like so
Code:
<WebIncludes:leftNav pageName="improvingIAQ" runat="server"/>
Then each of the links has an inline function:
Code:
class="<% response.write(getSupplimentalClass("improvingIAQ")) %>
and the function:
Code:
Public function getSupplimentalClass(anchorId) as string
Dim returnString as string = ""
if anchorId = pageVar
returnString = "activeLink"
end if
return returnString
end function
Not too complicated, but you can see the inherant problem, too much hard coding of strings. If I want to change the name of the page, I have then change the param I pass to my control, and then the param I pass to my inline function.
I thought of passing ordinals, like 1 or 2 to the control, but I would like something more descriptive. I have many pages, and remembering that "cleaningTips.aspx" is page 10 is a pain, and what if I change the order?
Any tips/comments/suggestions are much appriciated.
Can I throw one more requirement? I don't want my control based on a form. I don't want to use <asp:a > although that might make my life simpler, because then my page will not validate, which is a project requirement.
Thanks again
CJB