31

I am facing issue with regards to the TreeView control. I have checkbox enabled for nodes of TreeView control. It is working fine and showing properly. But when I deploy same to IIS, checkbox is not visible there. It is not rendered at all. Below is the TreeView:

<asp:TreeView id="tvExplicit"
        EnableClientScript="true"
        PopulateNodesFromClient="true"  
        ExpandDepth="0" 
        ShowLines="true" 
        ShowExpandCollapse="true"
        ShowCheckBoxes="Root"
        OnTreeNodePopulate="tvExplicit_TreeNodePopulate"
        Width="1px"
        runat="server">

    <Nodes>
    </Nodes>

  </asp:TreeView> 

This code is working fine on my local machine. But not when deployed on IIS. Everything works except showing checkboxes for root nodes.

Note: Checkboxes are not rendered as HTML at all. So it is not CSS blocking it as per me

Update : I was able to figure out that previous version of the page is cached in IIS and not being reset even after APP pool was reset.

2nd Update: Client Id of checkboxes in localhost is ctl00_MainContent_tvExplicitn0CheckBox, ctl00_MainContent_tvExplicitn1CheckBox,etc. So can it be the reason of the issue. One more thing that I noticed is the difference in client ID's generated for the controls in localhost and in server deployed to IIS. Below is the rendered <a> which is part of treeview control in both:

  1. IIS: MainContent_tvExplicitt0,MainContent_tvExplicitt1 this is ID of treeview node link
  2. LocalHost: ctl00_MainContent_tvExplicitt0,ctl00_MainContent_tvExplicitt2,etc

So can the issue be related to how controls are actually being rendered in different environments viz my localhost and IIS server. In localhost, .Net 3.5 framework is there and in IIS server .Net 4 . So can it be due to this as client ID generation is different in both versions.

3rd Update Also, I changed framework version to .net 4 in localhost, but it didn't reproduce the issue.It also did add controlRenderingCompatibilityVersion="3.5" in web.config. Then I deployed same code to IIS, and I got an error that controlRenderingCompatibilityVersion is not a valid tag. Does it mean IIS server is not running on .net 4.I don't have access to IIS server myself.

4th Update: Application is configured with .net 4 version in IIS.

5th Update I deployed same build to another IIS server on different machines(these were our old servers on which our application was running). And checkboxes are visible on that. Version of .net framework is same as that on the one facing issues. Asked the relevant team to update same settings as in these servers to servers on which are facing issue. Still it didnt help. So, it does seem to be issue with how website is configured on new servers where checkboxes are not visible

Ubaid Ashraf
  • 1,049
  • 5
  • 15
  • 43
  • sounds like an IIS mime type issue or something like that, do you have Fiddler or some other kind of request monitor open? Do you get any 404 for Javascript, images or something else? – Pedro Luz Jan 27 '17 at 12:24
  • 1
    Are the CheckBoxes present in the HTML? If so then there is a CSS class interferring i guess. – VDWWD Jan 27 '17 at 15:46
  • No, checkboxes are not rendered as HTML. @VDWWD – Ubaid Ashraf Jan 28 '17 at 04:38
  • can you tell which .net framework you are working? –  Feb 01 '17 at 17:19
  • What's in the `TreeTest_TreeNodePopulate` event/method? – user1429080 Feb 02 '17 at 07:03
  • It is the method which populates the child nodes @user1429080 – Ubaid Ashraf Feb 03 '17 at 06:34
  • @satsvelke .net 4.5 framework – Ubaid Ashraf Feb 03 '17 at 06:34
  • By any chance, are you using the generated clientID of checkboxes in your JS or jquery code for any sort of manipulation? – Rupa Mistry Feb 21 '17 at 09:09
  • Check Debug console in the browser. When JavaScript exceptions occur before tree control is rendered, or there is JavaScript or JQuery referencing those IDs and fails, it can prevent the boxes rendering to client. What causes this can be old tech or bad IIS config, or IIS wasn't fully restarted. Also an older or bad JS file can be cached in IIS. It may be necessary to make a change to the JS file (add a space) and republish. – HouseCat Feb 21 '17 at 13:35

4 Answers4

8

Not an answer yet, needed to show the images, well I tried the same, used this code in aspx: (I did not change any setting in IIS, nothing in aspx as well, created a plain solution >> added the treeview and deployed.)

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server"> 
    <div> 
        <asp:TreeView ID="TreeTest"
            EnableClientScript="true"
            PopulateNodesFromClient="true"
            ExpandDepth="0"
            ShowLines="true"
            ShowExpandCollapse="true"
            ShowCheckBoxes="Root"
            OnTreeNodePopulate="TreeTest_TreeNodePopulate"
            Width="1px"
            runat="server"> 
            <Nodes>
                <asp:TreeNode Text="Something">
                    <asp:TreeNode Text="11"></asp:TreeNode>
                </asp:TreeNode>
                <asp:TreeNode Text="Something">
                     <asp:TreeNode Text="11"></asp:TreeNode>
                </asp:TreeNode>
                <asp:TreeNode Text="Something"></asp:TreeNode>
            </Nodes> 
        </asp:TreeView>  
    </div>
</asp:Content>

Checked in my local could see this: enter image description here

Deployed in IIS version 6.2 , windows server 2012, could see this: enter image description here

There must be something else which is preventing the checkboxes in your page. Show more code.

Akshay
  • 1,412
  • 2
  • 17
  • 51
  • Issue is previous version of the code is not being reset from cache. Application pool was reset, still. @Sak – Ubaid Ashraf Feb 02 '17 at 11:48
  • @ubaidashraf So is your problem still there ? – Akshay Feb 02 '17 at 12:25
  • Yes , Issue is still there @Sak – Ubaid Ashraf Feb 03 '17 at 06:31
  • 1
    @ubaidashraf Show more code, otherwise this is all we can do. – Akshay Feb 03 '17 at 07:08
  • Need to see the populate treenode method. If this is a DB query for example, I would say no data is returning and the nodes don't get filled. If the IIS web server can't reach the SQL server or is blocked by firewall etc, you won't get data either. If you have the check boxes databound to a specific value its not receiving, checkbooks may fall to render. – HouseCat Feb 21 '17 at 13:23
  • Correct, But looks like he is able to connect to DB from IIS, otherwise he would be asking some different question. I really wanted to see more code here. – Akshay Feb 21 '17 at 13:28
  • Furthermore, if there is a JavaScript exception (which you can detect in browser debug on page load) you may also not render check boxes. – HouseCat Feb 21 '17 at 13:29
5

Sometimes IIS is configured for a different version of IE than your local version, this could cause some compatibility issues.

I always add the following to my head element in my html files:

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

There is more info here:

https://msdn.microsoft.com/en-us/library/jj676913(v=vs.85).aspx

DafyddNZ
  • 234
  • 2
  • 12
  • Already have treeview in another page for which I am not facing this issue. It is specific to this page only after deployed to IIS. On both the pages, html and server code is identical – Ubaid Ashraf Feb 01 '17 at 04:52
  • Hi @ubaidashraf, is this other page on the same website? If not, do you have access to the IIS server to check which application pools the websites are running? They may have different .NET CLR versions. – DafyddNZ Feb 01 '17 at 21:37
  • Hi @ubaidashraf, if you believe it is a caching issue, then this article may help: https://www.iis.net/learn/manage/managing-performance-settings/walkthrough-iis-output-caching – DafyddNZ Feb 02 '17 at 20:21
  • Other pages on the same website with same treeview control are not facing issue. – Ubaid Ashraf Feb 03 '17 at 03:56
  • Problem is, we don't deploy on IIS ourselves and have third party doing it for us using their tools as we are not allowed to do so. – Ubaid Ashraf Feb 03 '17 at 03:57
  • That is why I had already raised ticket to them to reset app pool, which they did, but issue is persistant. They had made some changes with respect to their deployment tools which we use. Deploying same code on old configuration/servers resolves the issue. But then I need to deploy on new servers. So I guess, it is more of environmental issue due to introduction of new IIS deployment tools.And I am 100% sure that it is caching issue now – Ubaid Ashraf Feb 03 '17 at 04:00
0

If you want to test whether it's the control names and you're using code to create the checkboxes, you could set the clientid property for the controls you're working with to Static, update the code that manages it to use just the control id, and then see if the code works.

user830154
  • 11
  • 1
  • 1
-1

Go to your IE\tools \ Compatibilty view Setting and press Add in order to add your URL into the list , then try load your Webpage again .

Hope it helps

Regards

MAHDI
  • 24
  • 3