Working with CSS and ASP.NET

If you are like us, you get someone else to do your skins for your website. When doing so, they may be unaware of how skinning, themes etc work in the ASP.NET world. As a matter of fact, the better they are, the less they will know about it. As I work through implementing the unbelievable sweet skin that we hired XHTMLIZED.COM to create for us, I have found a few issues that I will post here so that I can give better instructions to the next skinner, which will most likely be xtmlized.com.

1)       Don’t create a “label” css class as it interferes with .NET labels… especially when you set it’s left location to -99999.99

2)       If you are using stylesheets and themes, know that if you have “url(../images/someImage.jpg)” in your stylesheet, it doesn’t point to where you think it does. If your stylesheet is in your themes dir, it is relative to your themes dir.

3)       There are a lot of problems if your CSS uses “ID” to signify the style it needs, as obviously this has meaning in an ASP.NET control. Shane Henderson had a good idea. He suggested renaming all of the “#”’s to “.”’s so that they are all classes in the stylesheet.          

4)       If your CSS uses “LI” items for your menus, and you need to hide certain menu items, if you place your items in a “PlaceHolder” control you can turn em on and off with code by setting the visible property of the PlaceHolder. (Note: you can’t just set the visible to false on the Hyperlink as the “LI” tag still exists and will muck with your layout)

In your markup:

                    <asp:PlaceHolder runat="server" ID="plhAdmin">

                    <li><asp:HyperLink runat="server" ID="hlUsers" Text="Users" NavigateUrl="~/Admin/Users.aspx"></asp:HyperLink> </li>

                    <li><asp:HyperLink runat="server" ID="hlRoles" Text="Roles" NavigateUrl="~/Admin/Roles.aspx"></asp:HyperLink> </li>

                    <li><asp:HyperLink runat="server" ID="hlSubscriptions" Text="Subscriptions" NavigateUrl="~/Admin/ManageSubscriptions.aspx"></asp:HyperLink> </li>

                    </asp:PlaceHolder>

And in your Code:


        bool bIsAdmin = Page.User.IsInRole("Admin");

        plhAdmin.Visible = bIsAdmin;



Published Sunday, November 19, 2006 11:50 PM by wwright
Filed under: , , ,

Comments

Tuesday, November 21, 2006 8:52 AM by Web Links 11.21.2006 « Rhonda Tipton’s WebLog

# Web Links 11.21.2006 &laquo; Rhonda Tipton&#8217;s WebLog

Leave a Comment

(required) 
(required) 
(optional)
(required)