Solved

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

Posted on 2011-09-09
7
1,339 Views
Last Modified: 2012-05-12
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
Comment
Question by:ZekeLA
  • 4
  • 3
7 Comments
 
LVL 14

Expert Comment

by:shahprabal
ID: 36524986
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
 
LVL 1

Author Comment

by:ZekeLA
ID: 36539584
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
 
LVL 14

Expert Comment

by:shahprabal
ID: 36549533
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 14

Expert Comment

by:shahprabal
ID: 36551057
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
 
LVL 1

Author Comment

by:ZekeLA
ID: 36588156
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
 
LVL 1

Accepted Solution

by:
ZekeLA earned 0 total points
ID: 36589136
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
 
LVL 1

Author Closing Comment

by:ZekeLA
ID: 36715397
Found own solution
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Prologue It is often required to host multiple websites on a single instance of IIS, mostly in development environments instead of on production servers. I am sure it is not much a preferred solution on production servers but this is at least a pos…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now