views:

338

answers:

2

I having an issue with the ASP.NET Treeview control. I create the treeview just fine but the nodes will not expand or collapse. I see there is a javascript error but it is for line 1 character 0 of the webpage, there is nothing at line 1 character 0.

I am using the ASP:Treeview control in conjunction with the Telerik controls, but I'm not sure if that is an issue.

I saw there was a similar question here but the answer is not pertinent to my site. Has anyone run into this issue before? I've tried searching Google and tried a number of proposed solutions but so far none have worked.

Thank you,

+1  A: 

Normally with problems like this it is best to isolate the code which is causing the problem. For example, create a minimal page with no other controls or external JavaScript and see if the problem persists.

It's also useful to use a decent debugger. The latest IE8 actually has a very good Visual Studio-style JavaScript debugger built in - go to your page, hit F12 and the go to the Script tab and click 'Start Debugging' and see where that leads you.

Dan Diplo
@Dan - thank you ! didn't know about the IE script debugger. I'll give that a try !!
Scott Vercuski
You can also use Visual Studio to debug the javascript - if you're debugging the site with Visual Studio. When debugging, a "Script Documents" node will appear in the Solution Explorer, containing all the javascript documents your page is currently using. You can add breakpoints here.
Graham Clark
Also, the IE8 debugger has a Profiler (next tab over from Script). Run this, try to expand the TreeView, stop profiling, and you'll get a list of all the javascript that ran, in order. This should help you identify where the error occurred.
Graham Clark
I finally got the debugger going and it's hitting a file named ScriptResource.axd and crashing.
Scott Vercuski
ScriptResource.axd is the handler that includes all the ASP.NET Ajax javascript files, if that is any use.
Dan Diplo
+1  A: 

I've seen unhelpful javascript errors when a page does an AJAX postback, an exception occurs on the server, and the client javascript is unable to handle what the server returns. You could ascertain if this is happening by debugging the site, putting a breakpoint on the Page_Load method (or something similar), and see if it gets hit when trying to collapse or expand the TreeView.

Graham Clark
@Graham - Excellent idea !! I just tried it and it's not coming in as a postback. I'm trying the IE debugger, it doesn't seem to like the rather large viewstate that's crammed in the middle of the script unfortunately.
Scott Vercuski