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

Forums / Bugs & Issues / Error when using RadScriptManager in Template

Error when using RadScriptManager in Template

9 posts, 0 answered
  1. Phill Hodgkinson
    Phill Hodgkinson avatar
    362 posts
    Registered:
    10 Nov 2004
    14 Dec 2010
    Link to this post
    Hi there,

    I came across the following javascript error when using the RadScriptManager in my .master template file. 
    "Cannot call method 'sitefinityLocaleFormat' of null" 

    It's a bit obscure, but a bug just the same (unless RadScriptManager is officially not compatible with Sitefinity).

    Steps to reproduce:
    1. Create .master file with RadScriptManager and 2 content place holders.
    2. Create new template based on the .master file. Then in Design/Template, drop a RadSiteMap Widget onto the second place holder (nothing special about RadSiteMap, just bound to SiteMapDataSource)
    3. Then create new Page using the new template. Drop an Image gallery in the first place holder. Publish the page.
    4. Now try to edit the page and you should see the above error. The edit page becomes unusable since a simple javascript error can break so much of the required javascript funtionality (i.e. not able to delete the ImageGallery widget, top navigation that is still visible doesn't work).
    5. Simple fix is to either remote RadSiteMap from template (since it's the control that requires a ScriptManager) or change the RadScriptManager to an asp:ScriptManager. 

    Let me know if you need any more info to reproduce.

    Regards,
    Phill
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    15 Dec 2010
    Link to this post
    Hello Phill Hodgkinson,

    Thank you for using our services.

    Can you please tell us a little bit more about your project - localization setup for example, we have not been able to reproduce the issue by following the steps.

    We are currently making the Sitefinity pages automatically inject a ScirptManager if you have controls that require a script manager. You set the control to require a script manager using [RequireScriptManager] attribuge at the control's class definition (decorate the class with this attribute). This is how Sitefinity currently works. This means that you will not need to put a ScriptManager on the master page as long as your controls use this attribute.

    The current behavior is working with the ASP.NET ScriptManager. Our next weekly release will include RadScriptmanager. Our page will work with the RadScriptManager by default and will utilize all of its performance optimization techniques - script combining, script compression, etc.

    Greetings,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Phill Hodgkinson
    Phill Hodgkinson avatar
    362 posts
    Registered:
    10 Nov 2004
    15 Dec 2010
    Link to this post
    Hi Radoslav,

    Thanks for the response. If I'm not mistaken, adding the [RequireScriptManager] attribute would apply to a control created as a compiled dll. My Widget/control is just a UserControl with CodeBehind. Can I still add [RequireScriptManager] attribute to an asp UserControl? When trying to reproduce on your end did you use a compiled dll widget or a usercontrol widget? Finally, I'm not using any localization features. I have a number of other widgets on the page but was able to narrow down the issue to my RadSiteMap control (which gives an error if there's not ScriptManager on my page) by removing all the other widgets.

    I can zip up my master page and widget if that will help. Also, I'm running the latest build, 992.

    Regards,
    Phill
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    15 Dec 2010
    Link to this post
    Hi Phill Hodgkinson,

    Thank you for getting back to me.

    This attribute can be used to decorate user controls also. It was not clear to me whether you have used a compiled control or a user control from the first message. I have used SiteMapDataSource control and RadSiteMap directly from the Sitefinity toolbox for pages. Can you please show the markup of the script manager, do you have any script references, etc. I am using bellow code:

    .master file:
    <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Parent.master.cs" Inherits="SitefinityWebApp.Parent" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <telerik:RadScriptManager runat="server" ID="ScriptManager1"></telerik:RadScriptManager>
        <div>
            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
            </asp:ContentPlaceHolder>
        </div>
        </form>
    </body>
    </html>

    .ascx file:

    <telerik:RadSiteMap runat="server" DataSourceID="SiteMapDataSource" ID="SiteMap"></telerik:RadSiteMap>
    <asp:SiteMapDataSource runat="server" id="SiteMapDataSource" />

    .ascx.cs:
    [RequireScriptManager]
    public partial class MySiteMap: System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ((SiteMapBase)this.SiteMapDataSource.Provider).IsNodeAccessible += new EventHandler<IsAccessibleArgs>(SitePanelBar_IsNodeAccessible);
        }
        void SitePanelBar_IsNodeAccessible(object sender, IsAccessibleArgs e)
        {
            if (this.SiteMapDataSource.StartingNodeUrl == e.Node.Url.Replace("~/", ""))
            {
                e.IsAccessible = true;
                return;
            }
     
     
            var pageNode = e.Node as PageSiteNode;
            if (pageNode != null)
            {
                if (!pageNode.ShowInNavigation)
                {
                    e.IsAccessible = false;
                    return;
                }
                if (!pageNode.IsGroupPage && pageNode.ApprovalWorkflowStatus != "Published")
                {
                    e.IsAccessible = false;
                    return;
                }
            }
            else
            {
                throw new NotSupportedException("The supported types are 'TaxonSiteNode' or 'PageSiteNode'.");
            }
            e.IsAccessible = true;
        }
    }


    All the best,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Phill Hodgkinson
    Phill Hodgkinson avatar
    362 posts
    Registered:
    10 Nov 2004
    15 Dec 2010
    Link to this post
    Hi there,

    The following are my .master, ascx and ascx.cs files:

    .master file - note, in my tests to reproduce, I had two (more actually) content place holders. The error did NOT occur when the Sitemap was in the first place holder and the built in gallery in the second. It did occur regularly when the positions were reversed.
    <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Default.Master.cs" Inherits="SitefinityWebApp.Default" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
     
    <head runat="server">
        <title></title>
    </head>
    <body class="content">
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
            <div id="pageWrapper">
                <div id="topnavWrapper">
                    <div id="mainLogo">
                        <asp:Image ID="imgLogo" runat="server" ImageUrl="~/images/logo-1.gif" AlternateText="" Width="232" Height="65" style="display:block;" />
                    </div>
                    <div id="mainMenuLeft"><asp:Image ID="imgMenuSpace" runat="server" ImageUrl="~/images/left.gif" AlternateText="" Width="8" Height="65" style="display:block;" /></div>
                    <div id="mainMenu"><asp:ContentPlaceHolder ID="ContentMenuMain" runat="server"></asp:ContentPlaceHolder></div>
                    <div id="mainMenuRight"><asp:ContentPlaceHolder ID="ContentMenuLogin" runat="server"></asp:ContentPlaceHolder></div>
                </div>
                <div id="sliderWrapper">
                    <div class="sliderLeft"><asp:Image id="img_left" runat="server" ImageUrl="~/images/slider-left.gif" height="85" width="32" AlternateText="" /></div>
                        <div class="sliderContent sliderTitle">
                            <h1 id="pageTitle"><asp:ContentPlaceHolder ID="ContentPageTitle" runat="server"></asp:ContentPlaceHolder></h1>
                        </div>
                    <div class="sliderRight"><asp:Image id="img_right" runat="server" ImageUrl="~/images/slider-right.gif" height="85" width="32" AlternateText="" /></div>
                </div>
                <div id="contentWrapper">
                    <div id="contentLeft">
                        <div class="muGroup">
                            <div class="muTop">
                                <div class="muTopLeft"></div>
                                <div class="muTopCenter"></div>
                                <div class="muTopRight"></div>
                            </div>
                            <div class="muContent">
                                <div class="muMenu"><asp:ContentPlaceHolder ID="ContentSideMenu" runat="server"></asp:ContentPlaceHolder></div>
                            </div>
                            <div class="muBot">
                                <div class="muBotLeft"></div>
                                <div class="muBotCenter"></div>
                                <div class="muBotRight"></div>
                            </div>
                        </div>
                    </div>
                    <div id="contentMain">
                        <h3><asp:ContentPlaceHolder ID="ContentTitle" runat="server"></asp:ContentPlaceHolder></h3>
                        <asp:ContentPlaceHolder ID="ContentMain" runat="server"></asp:ContentPlaceHolder>
                    </div>
                </div>
                <div id="footerPush"></div>
            </div>
            <div id="footerWrapper">
                <div id="footerText"><asp:ContentPlaceHolder ID="ContentFooterText" runat="server"></asp:ContentPlaceHolder></div>
                <div id="footerFollow">
                    <asp:Image ID="imgFollow" runat="server" ImageUrl="~/images/txt-follow-us.gif" AlternateText="" Width="53" Height="18" style="margin-bottom:14px;" />
                    <a href="#"><asp:Image ID="imgFlwRss" runat="server" ImageUrl="~/images/button-follow-rss.gif" AlternateText="" Width="38" Height="38" /></a>
                    <a href="http://www.facebook.com/" target="_blank"><asp:Image ID="imgFlwFB" runat="server" ImageUrl="~/images/button-follow-facebook.gif" AlternateText="" Width="38" Height="38" /></a>
                    <a href="http://twitter.com" target="_blank"><asp:Image ID="imgFlwTW" runat="server" ImageUrl="~/images/button-follow-twitter.gif" AlternateText="" Width="38" Height="38" /></a>
                </div>
                <div style="width:970px;height:20px;clear:both;"><!--clear--></div>
                <div id="footerSiteMap">
                    <asp:ContentPlaceHolder ID="ContentFooterSitemap" runat="server"></asp:ContentPlaceHolder>
                </div>
            </div>
        </form>
    </body>
    </html>

    .master.cs file:
    protected override void OnPreRender(EventArgs e)
    {
        // Register Client Scripts
        if (!this.IsDesignMode())
        {
            this.Page.ClientScript.RegisterClientScriptInclude("jquery", "/custom/scripts/jquery.js");
            this.Page.ClientScript.RegisterClientScriptInclude("cufon", "/custom/scripts/cufon.js");
            this.Page.ClientScript.RegisterClientScriptInclude("cufon.font", "/custom/scripts/default.font.js");
            this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "initcufon", "Cufon.replace('#pageTitle');", true);
        }
        base.OnPreRender(e);
    }
     
    protected void Page_Load(object sender, EventArgs e)
    {
     
    }

    SiteMap Widget .ascx file
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="FooterSitemap.ascx.cs" Inherits="SitefinityWebApp.Custom.Navigation.FooterSitemap" %>
    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false"  />
    <telerik:RadSiteMap runat="server" ID="SiteMap1" DataSourceID="SiteMapDataSource1"
    MaxDataBindDepth="2"
    ShowNodeLines="false"
    OnNodeDataBound="SiteMap_OnNodeDataBound"
    Width="900"
    EnableEmbeddedSkins="false">
        <LevelSettings>
            <telerik:SiteMapLevelSetting Level="0"
                ListLayout-RepeatDirection="Horizontal"
                ListLayout-RepeatColumns="6"
                ListLayout-AlignRows="true"
                MaximumNodes="6"
                 >
                 </telerik:SiteMapLevelSetting>
            <telerik:SiteMapLevelSetting Level="1" ListLayout-RepeatDirection="Vertical" Width="100"></telerik:SiteMapLevelSetting>
        </LevelSettings>
    </telerik:RadSiteMap>

    SiteMap Widget .ascx.cs file
    protected void Page_Load(object sender, EventArgs e)
    {
     
    }
     
    protected void SiteMap_OnNodeDataBound(object sender, RadSiteMapNodeEventArgs e)
    {
        if (e.Node.Text == "Home")
            e.Node.Remove();
    }

    Then the Gallery Widget is just the built in one. Note that in sample above it's the working version where I've changed RadScriptManager to asp:ScriptManager. 

    Hope this helps.
    Cheers,
    Phill
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    16 Dec 2010
    Link to this post
    Hi Phill Hodgkinson,

    I think that the problem is caused by the client scripts registered in the OnInit event handler. I think that is because the last two. I am not including them as I do not have those particular script files. In this case the template is not failing with the above mentioned steps to reproduce.

    All the best,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Phill Hodgkinson
    Phill Hodgkinson avatar
    362 posts
    Registered:
    10 Nov 2004
    16 Dec 2010
    Link to this post
    Hi Radoslav,

    Thanks again for investigating. In the next couple days, when I have time, I'll try to create a simplified project that replicates issue and zip it up and send via a ticket. I'm 99% sure in my testing to isolate issue I removed the jquery scripts that were added in code behind of master page, but I'll remove them again just to double check as well.

    Thanks,
    Phill
  8. Phill Hodgkinson
    Phill Hodgkinson avatar
    362 posts
    Registered:
    10 Nov 2004
    19 Dec 2010
    Link to this post
    Hi Radoslav,

    I have a related question/update here. I attempted to add:
    [RequireScriptManager]
    public partial class FooterSitemap : System.Web.UI.UserControl

    as previously mentioned I didn't have the RequireScriptManager attribute in my user control. You said that if I add this that I wouldn't need to include the ScriptManager in my master page. So I added this, and then removed the script manager from my page. Now I get an error that my RadMenu requires a script manager on the page (custom menu created w/ user control). So I added the RequireScriptManager attribute to my menu as well like this:
    [RequireScriptManager]
    public partial class CustomMenu : System.Web.UI.UserControl

    however I still get the error that ScriptManager is required. So I'm back to having to add the asp:ScriptManager back to the page. Am I doing something wrong or is this a known bug?

    Regards,
    Phill
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    20 Dec 2010
    Link to this post
    Hello Phill,

    We made some modifications in the code that will be included in the next internal release later this week. Please upgrade your project once the build is out and let us know whether the problem still occurs.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
9 posts, 0 answered