[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1479
  • Last Modified:

ASP.NET TreeView control works in nested web application but not in parent

I have an existing (VS 2005) ASP.NET 2.0 application that was converted from a 1.1 application earlier this year. The control will display the text links and postback when a node is selected. But the expand/collapse images don't appear. In IE 7, there's a missing missing image icon and clicking on it gives a javascript "object expected" error. In FF, the page gives a WebForm_InitCallback is not defined error and clicking on the missing image text links gives TreeView_ToggleNode is not defined.

If I create a brand new website from VS, the tree view control works fine. In my production environment, the same is true: if I create a new website that is nested under the production website, the tree view control works just fine. If I copy the treeview page to the root of the production website, I get the display problems I mentioned.

On my development machine, the treeview control will work even if I use the web.config file from my converted web application. But if I copy the working treeview page to the root of the converted web application, I get the display problems.

I've included a screenshot of the page when it doesn't work as well as the source code. I know there's something going wrong with WebResource.axd but I don't know how to fix it.

Thanks in advance.

TreeView Display Problem
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="TreeView2.aspx.vb" Inherits="TreeView2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>TreeView2</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:TreeView ID="MyTreeView" Runat="server">
        <Nodes>
          <asp:TreeNode Value="Child1" Expanded="True" Text="1">
            <asp:TreeNode Value="Grandchild1" Text="A" />
            <asp:TreeNode Value="Grandchild2" Text="B" />
          </asp:TreeNode>
          <asp:TreeNode Value="Child2" Text="2" />
          <asp:TreeNode Value="Child3" Expanded="True" Text="3">
            <asp:TreeNode Value="Grandchild1" Text="A" />
            <asp:TreeNode Value="X2" Text="Z" >
               <asp:TreeNode Value="X2a" Text="Z.A" />
               <asp:TreeNode Value="X2b" Text="Z.B" />
            </asp:TreeNode>
          </asp:TreeNode>
        </Nodes>
      </asp:TreeView>
    </div>
    </form>
</body>
</html>

Open in new window


<?xml version="1.0"?>
<!-- 
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    \Windows\Microsoft.Net\Framework\v2.x\Config 
-->
<configuration>
   <appSettings/>
	<connectionStrings/>
	<system.web>
		<!-- 
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.

            Visual Basic options:
            Set strict="true" to disallow all data type conversions 
            where data loss can occur. 
            Set explicit="true" to force declaration of all variables.
        -->
		<compilation debug="true" strict="false" explicit="true"/>
		<pages>
			<namespaces>
				<clear/>
				<add namespace="System"/>
				<add namespace="System.Collections"/>
				<add namespace="System.Collections.Specialized"/>
				<add namespace="System.Configuration"/>
				<add namespace="System.Text"/>
				<add namespace="System.Text.RegularExpressions"/>
				<add namespace="System.Web"/>
				<add namespace="System.Web.Caching"/>
				<add namespace="System.Web.SessionState"/>
				<add namespace="System.Web.Security"/>
				<add namespace="System.Web.Profile"/>
				<add namespace="System.Web.UI"/>
				<add namespace="System.Web.UI.WebControls"/>
				<add namespace="System.Web.UI.WebControls.WebParts"/>
				<add namespace="System.Web.UI.HtmlControls"/>
			</namespaces>
		</pages>
		<!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
        -->
		<authentication mode="Windows"/>
		<!--
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->
	</system.web>
</configuration>

Open in new window


0
ZekeLA
Asked:
ZekeLA
  • 4
  • 3
1 Solution
 
shahprabalCommented:
try deleting the WebResource.axd file and let it recreate it. You can click the 'display all files' icon to see it.Have you tried create a new trewview control at the root and see if that works instead of copying it from somewhere else? If that works then you can copy the node info into the working tree tags.
0
 
ZekeLAAuthor Commented:
Thank you for your response.

1. This is a web site project, so all files are shown by default. WebResource.axd doesn not exist in these types of projects. I believe it's not a physical file but an httphandler,.

2. I tried creating a new web page at the root and added a treeview control from the VS toolbox and added nodes via the markup but it still had the same problem.

Per this url (http://bloggingabout.net/blogs/vikas/archive/2007/12/02/tricky-webresource-axd.aspx), I unchecked the "check if file exists" checkbox for the .axd extension but that had no effect, even after restarting IIS.

I'm still at a loss here.
0
 
shahprabalCommented:
I think I have got it. Since you are getting js error, either something got messed up in the 2003>2005 upgrade or it can't find the relative path of the js file. Try copying the js code from the new project where treeview works into your page and overwrite the existing js.
Also see if this helps : http://www.codeproject.com/KB/webforms/ClientSideTreeView.aspx
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
shahprabalCommented:
Ok, I created a sample website and replicated what you did without errors. What you can do is have the same page with the treeview control under the root and compare the axd's. You can also set a breakpoint and see where the js is failing. axd files
0
 
ZekeLAAuthor Commented:
I'm not sure where you want me to copy the js code from. There is no scripts folder for my project as you can see from this screenshot. TreeView Solution Explorer
This weekend I'll try copying files from the bad project into the good project and see if it stops working. I may also just consider upgrading to VS 2010 and see if that makes a difference.
0
 
ZekeLAAuthor Commented:
I found the problem. In past development, I had added a WhitespaceFilter to the project to reduce the amount of information going to the client. I just turned it off and the sample treeview page worked just fine.
0
 
ZekeLAAuthor Commented:
Found own solution
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now