find method

2 posts, 0 answers
  1. Mehrdad
    Mehrdad avatar
    9 posts
    Member since:
    Mar 2009

    Posted 07 Mar 2009 Link to this post

    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 ?

     

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 11 Mar 2009 Link to this post

    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


Back to Top