More in this section

Forums / Developing with Sitefinity / RadScript Manager in Page Template

RadScript Manager in Page Template

9 posts, 0 answered
  1. Samir Vaidya
    Samir Vaidya avatar
    261 posts
    Registered:
    05 Feb 2005
    31 Jul 2011
    Link to this post
    I would like to add an instance of the Telerik RadScriptManager to the Page Template that I have created directly through Sitefinity.  If possible, I would like to avoid having to create a special Master Page and upload this Master Page to Sitefinity since I would like my content managers to be able to easily define and design new Layouts without relying on a Master Page created by developers in Visual Studio.

    Is there a way to add the RadScriptManager directly to a Sitefinity-designed Page Template without using a Master Page file?
  2. Samir Vaidya
    Samir Vaidya avatar
    261 posts
    Registered:
    05 Feb 2005
    31 Jul 2011
    Link to this post
    I am using Sitefinity v. 4.1 SP3.

    I have noticed that if I preview a Page that I have created directly through Sitefinity, the Preview seems to render fine.  However, after I publish the Page and attempt to ACTUALLY view the page through the website, I receive the following error message:

    The control with ID '' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.InvalidOperationException: The control with ID '' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.

    Source Error: 

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace: 

    [InvalidOperationException: The control with ID '' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.]
       System.Web.UI.UpdatePanel.get_ScriptManager() +480872
       System.Web.UI.UpdatePanel.RegisterPanel() +2524385
       System.Web.UI.UpdatePanel.OnInit(EventArgs e) +19
       System.Web.UI.Control.InitRecursive(Control namingContainer) +140
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Control.AddedControl(Control control, Int32 index) +197
       System.Web.UI.ControlCollection.Add(Control child) +79
       Telerik.Web.UI.RadCaptcha.CreateChildControls() +480
       System.Web.UI.Control.EnsureChildControls() +102
       Telerik.Web.UI.RadCaptcha.OnInit(EventArgs e) +30
       System.Web.UI.Control.InitRecursive(Control namingContainer) +140
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Control.AddedControl(Control control, Int32 index) +197
       System.Web.UI.ControlCollection.Add(Control child) +79
       System.Web.UI.WebControls.TableWizardRendering.CreateControlHierarchy_CreateStepArea(Table mainContentTable) +225
       System.Web.UI.WebControls.TableWizardRendering.CreateControlHierarchy() +59
       System.Web.UI.WebControls.Wizard.CreateControlHierarchy() +18
       System.Web.UI.WebControls.Wizard.CreateChildControls() +221
       System.Web.UI.Control.EnsureChildControls() +102
       System.Web.UI.WebControls.Wizard.OnInit(EventArgs e) +107
       System.Web.UI.Control.InitRecursive(Control namingContainer) +140
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +480

    Why does this error occur when I am viewing the page in the Live site but not when I am previewing it through the Page Editor view?
  3. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    30 Oct 2017
    01 Aug 2011
    Link to this post
    Hi Samir Vaidya,

    That's a tough one. If you want to avoid usage of masterpages, than you can simply check the Include RadScriptManager from the page's title and properties. If you have a user control that explicitly requires ScriptManager to be loaded, you can set [RequireScriptManager] in its code-behind like this:
    using System;
    using Telerik.Sitefinity.Modules.Pages.Web.UI;
    using Telerik.Web.UI;
      
    namespace SitefinityWebApp
    {
        [RequireScriptManager]
        public partial clas smyusercontrol : System.Web.UI.UserControl

    Regards,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  4. Samir Vaidya
    Samir Vaidya avatar
    261 posts
    Registered:
    05 Feb 2005
    02 Aug 2011
    Link to this post
    I checked the property for Include RadScriptManager for my Page since I could not include it at the Page Template level.  However, when I did this, I continue to experience this error message.

    It is not until I included the RadScriptManager inside of my .ascx conrol that the error message disappears for me.  However, including this in my .ascx control now introduced unexpected behavior for my user control that was not present while using Sitefinity v. 3.7 with Master Pages.

    This was the original code in my Master Page:

    <body>
        <form id="frmTTAMain" runat="server">
        <div>
            <telerik:radscriptmanager id="radScriptMgr" runat="server" />
        <telerik:radajaxmanager id="radAjaxMgr" runat="server" enableajax="false" />
            <asp:contentplaceholder id="cphBody" runat="server">
                <table width="100%" border="0" align="center" cellspacing="0" bgcolor="#FFFFFF">
                    <tr>
                        <td height="145" align="left">
                            <asp:image imageurl="~/Images/TTA_pg2_headr.jpg" alternatetext="Troy Tennis Academy" runat="server" />
                        </td>
                        <td height="145">
                            <asp:contentplaceholder id="cphTopNavigation" runat="server" />
                        </td>
                          
                    </tr>
                    <tr>
                        <td height="161" valign="top">
                            <asp:contentplaceholder id="cphLeftBody" runat="server" />
                        </td>
                        <td colspan="5" valign="top">
                            <asp:contentplaceholder id="cphMainBodyContent" runat="server" />
                        </td>
                    </tr>
                    <tr bgcolor="#eee800">
                        <td height="60" colspan="6" align="center">
                            <asp:contentplaceholder id="cphFooter" runat="server" />
                        </td>
                    </tr>
                </table>
            </asp:contentplaceholder>
        </div>
        </form>
    </body>


    This is the code in my User Control that is now breaking using Sitefinity v. 4.1 SP3 without Master Pages and including the RadScriptManager directly in the User Control:

    <asp:wizardstep id="wizStepClassReg" title="Class Registration" runat="server" steptype="Step">
               <telerik:radajaxmanagerproxy id="radAjaxMgrProxy" runat="server">
                   <ajaxsettings>
                       <telerik:ajaxsetting ajaxcontrolid="ddlSubject">
                           <updatedcontrols>
                               <telerik:ajaxupdatedcontrol controlid="gv" loadingpanelid="radAjaxLoadingPanel" />
                           </updatedcontrols>
                       </telerik:ajaxsetting>
                   </ajaxsettings>
               </telerik:radajaxmanagerproxy>
               <telerik:radajaxloadingpanel id="radAjaxLoadingPanel" runat="server" skin="Outlook" />
               <asp:validationsummary id="vldSummaryCourseSelection" validationgroup="selectedCourses"
                   displaymode="SingleParagraph" showmessagebox="true" runat="server" forecolor="Red" />
               <asp:customvalidator id="vldCustomCourseSelection" runat="server" onservervalidate="vldCustomCourseSelection_ServerValidate"
                   validationgroup="selectedCourses" errormessage="Please select at least one course for registration"
                   display="None" />
                   <table>
                       <tr>
                           <td>
                               <asp:label id="lblFilterSubject" runat="server" associatedcontrolid="ddlSubject" text="Filter by Subject:" />
                               <telerik:radcombobox id="ddlSubject" runat="server" markfirstmatch="true" allowcustomtext="true"
                                   onselectedindexchanged="ddlSubject_SelectedIndexChanged" autopostback="true" />
                           </td>
                       </tr>
                   </table>
                   <telerik:radgrid id="gv" autogeneratecolumns="false" showfooter="false" runat="server"
                       cellspacing="0" gridlines="None" allowpaging="true" allowsorting="true" skin="Outlook"
                       onpageindexchanged="RadGrid1_PageIndexChanged" showgrouppanel="false" onsortcommand="RadGrid1_SortCommand"
                       onpagesizechanged="RadGrid1_PageSizeChanged" onitemdatabound="gv_ItemDataBound">
                       <mastertableview datakeynames="CourseID" pagesize="25">
                           <commanditemsettings exporttopdftext="Export to Pdf"></commanditemsettings>
                           <rowindicatorcolumn filtercontrolalttext="Filter RowIndicator column">
                           </rowindicatorcolumn>
                           <expandcollapsecolumn filtercontrolalttext="Filter ExpandColumn column">
                           </expandcollapsecolumn>
                           <groupbyexpressions>
                               <telerik:gridgroupbyexpression>
                                   <selectfields>
                                       <telerik:gridgroupbyfield fieldalias="AgeGroup" fieldname="CategoryDesc" />
                                       <telerik:gridgroupbyfield fieldalias="Subject" fieldname="SubjectDesc" />
                                   </selectfields>
                                   <groupbyfields>
                                       <telerik:gridgroupbyfield fieldname="CategoryDesc" sortorder="None" />
                                       <telerik:gridgroupbyfield fieldname="SubjectDesc" sortorder="None" />
                                   </groupbyfields>
                               </telerik:gridgroupbyexpression>
                           </groupbyexpressions>
                           <columns>
                               <telerik:gridboundcolumn uniquename="CourseID" readonly="true" display="false" datafield="CourseID" />
                               <telerik:gridtemplatecolumn>
                                   <itemtemplate>
                                       <asp:checkbox runat="server" id="chk" oncheckedchanged="CheckChanged" autopostback="true" />
                                   </itemtemplate>
                               </telerik:gridtemplatecolumn>
                               <telerik:gridboundcolumn headertext="Age Group" datafield="CategoryDesc" />
                               <telerik:gridboundcolumn headertext="Subject" datafield="SubjectDesc" />
                               <telerik:gridboundcolumn uniquename="CourseDescription" datafield="CourseDescription"
                                   headertext="Ages" />
                               <telerik:gridboundcolumn headertext="Term" datafield="term.TermDesc" />
                               <telerik:gridboundcolumn headertext="Course Cost" datafield="Cost" dataformatstring="{0:C}" />
                               <telerik:gridboundcolumn headertext="Length (Weeks)" datafield="CourseLength" />
                               <telerik:gridboundcolumn headertext="Days" datafield="Days" />
                               <telerik:gridboundcolumn headertext="Start Time" datafield="StartTime" />
                               <telerik:gridboundcolumn headertext="End Time" datafield="EndTime" />
                               <telerik:gridboundcolumn headertext="Location" datafield="location.LocationDesc" />
                           </columns>
                           <editformsettings>
                               <editcolumn filtercontrolalttext="Filter EditCommandColumn column">
                               </editcolumn>
                           </editformsettings>
                       </mastertableview>
                       <headercontextmenu cssclass="GridContextMenu GridContextMenu_Default">
                       </headercontextmenu>
                   </telerik:radgrid>
           </asp:wizardstep>


    Please advise.
  5. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    30 Oct 2017
    02 Aug 2011
    Link to this post
    Hi Samir Vaidya,

    Can you try adding the RadAjaxManager through the code-behind like this:
    protected void Page_Load(object sender, EventArgs e)
            {     
      
            }
            protected override void OnInit(EventArgs e)
            {
                base.OnInit(e);
                if (!this.IsDesignMode())
                {
                    RadAjaxManager ajaxManager = new RadAjaxManager();
                    //get the index of the script manager and add the ajax manager right after it
                    int index = this.form1.Controls.IndexOf(ScriptManager1);
                    this.form1.Controls.AddAt(index + 1, ajaxManager);
      
                    //please check the EnableViewState checkbox in the Page's title&properties
                    //as the OnInit event might be too early to enable ViewState programatically
                    // this.Page.EnableViewState = true;
                      
                    base.OnInit(e);
                }
            }


    Best wishes,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Samir Vaidya
    Samir Vaidya avatar
    261 posts
    Registered:
    05 Feb 2005
    03 Aug 2011
    Link to this post
    Is there a way to force the ScriptManager to be loaded without a reference to the Sitefinity modules in the code behind?  I have a separate Web Application that I am using to develop the User Controls and I would like to avoid coupling that web application to the Sitefinity web application.  
     Even when I check the "Include RadScriptManager" in my Page, it does not seem to allow my User Control to load based on its dependency with the Telerik RadScriptManager.  
  7. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    30 Oct 2017
    03 Aug 2011
    Link to this post
    Hello Samir Vaidya,

    Irrelevant of the location of the controls you'll need to have
    1. Script Manager (it could either be asp:ScriptManager or telerik:RadScriptManager)
    2. AjaxManager
    loaded before everything else on that page, that's why you need to declare them in your masterpage, which is located in your SitefinityWebApp project

    3.In your control you'll need to use RadAjaxManagerProxy and if the control is not an AJAX control (e.g. asp:Button, you'll either need to substitute it with its Ajax equivalent (RadButton) or place it in an UpdatePanel

    4. Last but not least you need EnableViewstate to be checked int he SItefinity page's title and properties

    Kind regards,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. Joel
    Joel avatar
    40 posts
    Registered:
    30 Nov 2010
    16 Sep 2011
    Link to this post
    Hello Boyan,

    We have default sitefinity templates to build a page, I have an update panel on a user control.

    <asp:UpdateProgress ID="updProgress" runat="server" AssociatedUpdatePanelID="upnlMyExams" >
           <ProgressTemplate>
               <span style="position:absolute;">
                   <asp:Image id="imgUpdateprogress" runat="server"  />
               </span>
           </ProgressTemplate>
       </asp:UpdateProgress>
        
       <asp:UpdatePanel ID="upnlMyExams" runat="server" UpdateMode="Conditional" >      
           <ContentTemplate>
                    
                   <asp:Panel ID="pnlRetakeExam" runat="server">
                       <div style="float:right;padding:10px;" class="ui-widget ui-widget-content ui-corner-all">
                           <asp:LinkButton ID="lnkbtnReTakeExam" runat="server" Text="ReTake Exam"></asp:LinkButton>
                           <noscript>
                               <asp:Button ID="btnReTakeExam" runat="server" Text="ReTake Exam" />
                           </noscript>
                       </div>
                   </asp:Panel>


    I've checked the "Include ScritpManager" button and added [RequireScriptManager(true)] to the class declaration of my user control. Is there something that I'm missing here in order to force sitefinity to generate me a ScriptManger?

    [RequireScriptManager(true)]
    public partial class ClassExam : BaseUserControlAdvanced


    My user control inherits from a class called BaseUserControlAdvanced (which my crm requires me to use)- which, in turn, inherits from UserControl.

    Is there something that I'm missing here?

    Server Error in '/' Application.

    The control with ID 'upnlMyExams' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.InvalidOperationException: The control with ID 'upnlMyExams' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [InvalidOperationException: The control with ID 'upnlMyExams' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.]
       System.Web.UI.UpdatePanel.get_ScriptManager() +490228
       System.Web.UI.UpdatePanel.RegisterPanel() +2561633
       System.Web.UI.UpdatePanel.OnInit(EventArgs e) +19
       System.Web.UI.Control.InitRecursive(Control namingContainer) +140
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +480
    
  9. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    30 Oct 2017
    16 Sep 2011
    Link to this post
    Hi Joel,

    Can you please check the following blog post which we released in order to address this issue - it explains in detail the reasons for this behavior and how to deal with it.

    All the best,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested 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