January, 2009

  • Never doubt thy debugger

    Unable to get the private bytes memory limit for the W3WP process (reloaded)

    • 2 Comments

    Sometimes they come back, as my favorite writer says… This is the case of this error message I already wrote about a couple of years ago; anyway this time the customer before calling CSS for support had already tried the suggestions on my previous post, unfortunately without luck. The customer has tried:

    • aspnet_regiis -ga “Network Service”
    • cscript metaacl.vbs IIS://Localhost/W3SVC/AppPools IIS_WPG RE
    • Assured the account running Application Pool (NETWORK SERVICE) is part of the IIS_WPG group

    The difference this time is that the application’s files are hosted on a centralized network share; for this particular scenario, also the account used in the “Connect As…” dialog in IIS Manager must be part of the IIS_WPG group:

    Network Directory Security Credentials

     

    Carlo

    Quote of the day:
    I like nonsense, it wakes up the brain cells. Fantasy is a necessary ingredient in living, It's a way of looking at life through the wrong end of a telescope. Which is what I do, And that enables you to laugh at life's realities. - Dr. Seuss
  • Never doubt thy debugger

    TabContainer rendered incorrectly in Design View

    • 7 Comments

    One of the (very few) downsides I see working in Customer Support is that most of the times when talking to colleagues and friends or writing a new post for my blog, I find myself talking about problems, bugs, exceptions… what is not working fine, like a doctor most of the times has to deal with malaises and diseases. Anyway the good part is that most of the times we are able to find the solution to those problems, or at least we can alleviate them.

    This is the case of a problem I had with the Ajax TabContainer control which is not displayed correctly in Design View, where the Tab caption is not completely visible, as in the screenshot here below:

    Tab caption not completely visible

    But if we open the page in a real browser, it displays correctly:

    Tabs displayed correctly in browser

    This is part of a problem reported on the Connect site some time ago: http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=322477.

    This has to do with the !DOCTYPE (Document Type Definition, or DTD), which among other things influences how CSS styles, formatting and positioning are applied to the page and its UI elements. With DTD we can control IE’s strict standard compliance; for example in this case if we remove the DTD from the source code in Visual Studio, then the TabContainer control and its Tabs are displayed correctly:

    Tab caption rendered correctly without DTD

    But this just moves the problem to the real browser, where without strict compliance mode IE fails to render the tabs correctly:

    Tab wrong in browser without DTD

    Visual Studio uses it own rendering engine to show pages and controls in Design View, and this is the component which does not handles compatibility mode correctly; this is a known issue and as of now I know this problem is scheduled to be fixed in Visual Studio 2010, there is no plan for a fix for the current Visual Studio version.

    Anyway this real problem here is the difficulty to click on the Tab caption to switch between tabs at design time; other than that I’ve not heard or other issues but feel free to correct me if I’m wrong. So, if that is the real issue, a simple workaround a suggested to the customer is to select the TabContainer control and then in the “Properties” grid you can change the ActiveTabIndex value and press ENTER: this will give focus to the Tab you selected. Remember that this is a zero based array, so as in the sample here below if you want to switch to TabPanel5 you have to set ActiveTabIndex to 4:

    TAB index

     

    Hope this helps…

     

    Carlo

    Quote of the day:
    Tact is the knack of making a point without making an enemy. – Isaac Newton
  • Never doubt thy debugger

    HoverNodeStyle not applied with partial postback

    • 0 Comments

    The TreeView control has built-in Ajax capabilities when it comes to dynamically fill it nodes; this is done through the PopulateNodesFromClient:

    Sometimes, it is not practical to statically predefine the tree structure due to data size or custom content that depends on user input. Because of this, the TreeView control supports dynamic node population. When the PopulateOnDemand property for a node is set to true, that node gets populated at run time when the node is expanded.

    In addition to populating nodes on demand, it is possible to populate the nodes directly on a supported client browser. When the PopulateNodesFromClient property is set to true, a service is called from the client to populate the tree nodes, which eliminates the need to post back to the server. Otherwise, the TreeView control posts back to the server to populate the nodes.

    The EnableClientScript property must also be set to true in order for the PopulateNodesFromClient property to be set to true.

    Here's the sample page:

    <%@ Page Language="C#" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
               public void PopulateNode(Object sender, TreeNodeEventArgs e)
               {
                     for (int i = 0; i <= 5; i++)
                     {
                            TreeNode newNode = new TreeNode("Node number " + i.ToString());
                            newNode.PopulateOnDemand = true;
                            e.Node.ChildNodes.Add(newNode);
                     }
               }
    </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:TreeView ID="TreeView1" runat="server" PopulateNodesFromClient="true" OnTreeNodePopulate="PopulateNode" ExpandDepth="1"> <Nodes> <asp:TreeNode Text="Root" Value="Root"> <asp:TreeNode PopulateOnDemand="True" Text="First node" Value="First node"></asp:TreeNode> <asp:TreeNode PopulateOnDemand="True" Text="Second node" Value="Second node"></asp:TreeNode> <asp:TreeNode PopulateOnDemand="True" Text="Third node" Value="Third node"></asp:TreeNode> <asp:TreeNode PopulateOnDemand="True" Text="Fourth node" Value="Fourth node"></asp:TreeNode> </asp:TreeNode> </Nodes> <NodeStyle Font-Names="Arial" Font-Size="8pt" ForeColor="DarkBlue" HorizontalPadding="5" /> <RootNodeStyle Font-Bold="True" Font-Size="9pt" /> <HoverNodeStyle Font-Underline="True" ForeColor="Red" Font-Bold="true" /> </asp:TreeView> </div> </form> </body> </html>

    Anyway there is a problem: if you run the page you’ll see the ForeColor defined for HoverNodeStyle works as expected (the text turns red)

    First node with style

    But if you expand one of the nodes clicking on the “+” sign, something weird happens:

     Subnode with partial style

    As you can see, the sub nodes (added dynamically) do not turn red as they should, but only the underlining color changes… Important to note: the problem reproduces only if we click on the “+” sign to expand the node; this triggers a partial (Ajax like) postback, but if we click on the node name, by default we have a full page postback and the problem does not reproduce anymore. Why?

    According to the documentation, the value defined for HoverNodeStyle has precedence over other settings inherited from styles at higher levels:

    Common settings usually include a custom background color, foreground color, font properties, and node spacing. Style properties are applied in the following order:

    1. NodeStyle
    2. RootNodeStyle, ParentNodeStyle, or LeafNodeStyle, depending on the node type. If the LevelStyles collection is defined, it is applied at this time, overriding the other node style properties
    3. SelectedNodeStyle
    4. HoverNodeStyle

    The style settings for the HoverNodeStyle property override any corresponding node style settings that are in the NodeStyle, RootNodeStyle, ParentNodeStyle, LeafNodeStyle, or SelectedNodeStyle property

    Uhm… that doe not seem to be the case. Really? Are you sure? Smile

    Take a closer look at the second screenshot above, the one where the mouse pointer is over the “Node number 0” sub node: who has the eagle eye?

    The text is bold, and the bold style is defined only in HoverNodeStyle element; so this means the style is actually applied… Another thing: if we remove the FontColor element from NodeStyle, then the FontColor defined in HoverNodeStyle works as expected also with the partial postback! Surprised smile. So properties defined with the same name (we have FontColor both in NodeStyle and HoverNodeStyle) show the problem, while properties added at the lower level work fine.

    This means only one thing: when we have a partial postback the style properties are applied in the wrong order.

     

    So, do we have a solution? Of course… Nerd smile

    <%@ Page Language="C#" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
            public void PopulateNode(Object sender, TreeNodeEventArgs e)
            {
                for (int i = 0; i <= 5; i++)
                {
                    TreeNode newNode = new TreeNode("Node number " + i.ToString());
                    newNode.PopulateOnDemand = true;
                    e.Node.ChildNodes.Add(newNode);
                }
            }
    </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style .customNodeColor { color:GreenYellow !important } </style> </head> <body> <form id="form1" runat="server"> <div> <asp:TreeView ID="TreeView1" runat="server" PopulateNodesFromClient="true" OnTreeNodePopulate="PopulateNode" ExpandDepth="1"> <Nodes> <asp:TreeNode Text="Root" Value="Root"> <asp:TreeNode PopulateOnDemand="True" Text="First node" Value="First node"></asp:TreeNode> <asp:TreeNode PopulateOnDemand="True" Text="Second node" Value="Second node"></asp:TreeNode> <asp:TreeNode PopulateOnDemand="True" Text="Third node" Value="Third node"></asp:TreeNode> <asp:TreeNode PopulateOnDemand="True" Text="Fourth node" Value="Fourth node"></asp:TreeNode> </asp:TreeNode> </Nodes> <NodeStyle Font-Names="Arial" Font-Size="8pt" ForeColor="DarkBlue" HorizontalPadding="5" /> <RootNodeStyle Font-Bold="True" Font-Size="9pt" /> <HoverNodeStyle Font-Underline="True" ForeColor="Red" Font-Bold="true" CssClass="customNodeColor" /> </asp:TreeView> </div> </form> </body> </html>

    Note the use of !important to assure the style is not overridden; here is the result:

    First node with style, wrong

    Now also on sub node with partial postback we have the desired style:

    Subnode with style, working

     

    As of today, I’m still discussing this issue internally, as soon as I’ll have any news (if this will be recognized as a bug, if there will be a fix etc…) I’ll update the post Winking smile.

     

    Update (12 January, 2009):

    The solution above works fine on IE7 and IE8, but not IE6… for the latter, all the formatting must be applied through the CSS stylesheet with the !important attribute, as follows:

    <style>
          .customNodeColor 
          {
                 color:GreenYellow !important;
                 text-decoration: underline !important;
          }
    </style>

     

    Carlo

    Quote of the day:
    There is always a well-known solution to every human problem: neat, plausible, and wrong – H. L. Mencken
Page 1 of 1 (3 items)