This is a migrated thread and some comments may be shown as answers.

find method

1 Answer 92 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Mehrdad
Top achievements
Rank 1
Mehrdad asked on 07 Mar 2009, 03:17 PM
Hi.
I'm using TreeView 2007 on my page. I wrote this code in my javascript function :

var

treeView = $find("<%= MyTree.ClientID %>");
but this but when the code runs, this error appears:
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
I've tried this code too:
var tree = $find("MyTree"); 
but this error appears:
Microsoft JScript runtime error: Object expected

What's the reason ? Is it because of the old version or not ?

 

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 11 Mar 2009, 11:53 AM
Hi,

If you receive exceptions such as "System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks" you need to move the code block (i.e. <% ... %>) outside of the head tag. Here is a help article which explains more about this error. Go through the section under the heading:

Error message “The Controls collection cannot be modified because the control contains code blocks".

Thanks
Shinu


Tags
TreeView
Asked by
Mehrdad
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or