+1-888-365-2779
Try Now
More in this section

Forums / 3.x Pre-release forums (retired) / Javascript error when picking a template

Javascript error when picking a template

4 posts, 0 answered
  1. fregas baratis
    fregas baratis avatar
    185 posts
    Registered:
    14 Nov 2002
    17 Apr 2007
    Link to this post
    I'm not 100% sure its not some of our javascript messing this up, but it is sure acting like its a sitefinity error.  When editing a page, i can change the page template, but after the postback, i can't change it again.  I get a javascript error:

    Line:186
    Char: 5
    Error: object required.
  2. Slavo
    Slavo avatar
    13 posts
    Registered:
    21 May 2013
    19 Apr 2007
    Link to this post
    Hello Fregas,

    I tried to reproduce the error you get both with built-in templates in Sitefinity and my own, containing javascript functions. In both cases changing the template for a page works fine. It does not look like a Sitefinity error to me.
    I would gladly help you if you provide a project where I can observe the behaviour or if I could see the javascript you have in the template.

    All the best,
    Slavo
    the telerik team

    Instantly find answers to your questions at the new telerik Support Center
  3. fregas baratis
    fregas baratis avatar
    185 posts
    Registered:
    14 Nov 2002
    20 Apr 2007
    Link to this post
    I was about to zip up my files and send them to you, but like so many things in programming, i quit looking at it for a while (went to lunch) and when i came back i had the answer.  I used firebug in Firefox and the error was "el has no properties" 

    The error is in this piece of javascript which i believe is created by sitefinity.  I have highlighted in red the line that causes the error according to firebug:

    function () {
        var el;
        var str = "";
        if (document.getElementById("ctl00_toolBar_templates") != null) {
            el = document.getElementById("ctl00_toolBar_templates");
            str = "&cmstemplate=" + el.value;
        }
        el = document.getElementById("ctl00_toolBar_themes");
        str += "&cmstheme=" + el.value;
        var href = document.location.href;
        href = href.substring(0, href.indexOf("?"));
        document.location.href = href + "?cmspagemode=edit" + str;
    }

    The error consistently happens on templates where i am using nested master pages.  On templates that do not, its fine.  So i think you can just recreate the issue by nesting some master pages.  I think this is because the variable el is assigned to an element with the ID "ctl00_toolBar_themes" but when nesting the master pages, the control hierarchy is different and this element has a different Client ID.  I suspect this ID is hardcoded and instead should just be dynamically generated using the ClientID property and some databinding or setting a literal.

    I hope this helps.  If you absolutely need me to send you my project files i will.  But i think i found the cause and how to fix it.
  4. Bob
    Bob avatar
    330 posts
    Registered:
    24 Sep 2012
    20 Apr 2007
    Link to this post
    Hi fregas baratis,

    Thank you very much for your cooperation. We will fix this issue.

    Regards,
    Bob
    the telerik team

    Instantly find answers to your questions at the new telerik Support Center
Register for webinar
4 posts, 0 answered