if( treeview1.SelectedNode.Parent == null)  // that means your selected node is a root.else // that means your selected node is not a root. to know whether it is a parent node or a leafnodeif(treeview1.selectednode.childnodes.count == 0)  // its a child nodeelse //its a parent node.

解决方案 »

  1.   

    <asp:treeview ID="Treeview1"   CssClass="myclass"
    runat="server"></asp:treeview>
    <style type="text/css">.myclass a:visited {color:Fuchsia;}</style>
      

  2.   

    Wrong solution
    <asp:ImageButton id="ImageButton2" 
    onmouseover="this.src='../Images/textRoll.png'" 
    onmouseout="this.src='../Images/text.png'" 
    runat="server"
    ImageUrl="~/Images/text.png"></asp:ImageButton></td>Right Answer
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
        <script type="text/javascript" language=javascript>
        function mouseover(arg)
        {
        arg.src = "<%= Page.ResolveUrl("~/Image/028439.jpg") %>";
        }
        
        function mouseout(arg)
        {
         arg.src = "<%= Page.ResolveUrl("~/Image/012316.jpg") %>";
        }
        
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <asp:ImageButton id="ImageButton2" 
    onmouseover="mouseover(this)"
    onmouseout="mouseout(this)" 
    runat="server"
    ImageUrl="~/Image/007004.gif"></asp:ImageButton></
        </div>
        </form>
    </body>
    </html>
      

  3.   

    <link runat="server" 
          id="csslnk1" 
          href="~/MyStyles.css" 
          rel="stylesheet" type="text/css" />because the link is runat=server and were setting the href to ~/MyStyles.css, all your pages will get a proper link to the css stylesheet stored in the root of your app regardless of which subfolder your page is being pulled from.since you defined any background-image urls inside the actual css stylesheet as being relative to the root of your app (where the stylesheet is stored) then all images will be found - again regardless of which subfolder your page is being pulled from.
      

  4.   

    读书:Using the Site Navigation API
      

  5.   

    ex. void Application_PostAuthenticateRequest(Object sender, EventArgs e)
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated == true)
            {
                if (HttpContext.Current.User.Identity.Name.ToLowerInvariant() == "AllSections".ToLowerInvariant())
                    HttpContext.Current.User = new GenericPrincipal(HttpContext.Current.User.Identity,new string[]{"Administrators"});
                else
                    HttpContext.Current.User = new GenericPrincipal(HttpContext.Current.User.Identity, new string[] { "Regular Users" });
            }  
            
        }MSDN:
    // Construct a GenericPrincipal object based on the generic identity
            // and custom roles for the user.
            GenericPrincipal genericPrincipal =
                new GenericPrincipal(genericIdentity, roles);