RadScript Manager in Page Template
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?
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:
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. |
|
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
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
>
<
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
>
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);
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.
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
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
>
[RequireScriptManager(
true
)]
public
partial
class
ClassExam : BaseUserControlAdvanced
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.
|
[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 |
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