Hey folks.
For you guys struggling with one of the following errors (or both if you try to render a new ScriptManager)
- Only one instance of a ScriptManager can be added to the page.
- The control with ID 'xx' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.
The solution is to make sure that the ScriptManager is rendered BEFORE the given RAD Control, and that only one ScriptManager exists. The following code snippet should achive this:
protected override void CreateChildControls()
{
if (ScriptManager.GetCurrent(this.Page) != null)
{
this.sm = ScriptManager.GetCurrent(this.Page);
}
else
{
this.sm = new ScriptManager();
this.Controls.Add(this.sm);
}
}
Now make sure the ScriptManager is rendered BEFORE the controls needing it (ie RadEditor)
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
this.sm.RenderControl(writer);
this.radEditor.RenderControl(writer);
}
Hopefully this will be helpful to someone else.
| <div style="margin-left:50px; margin-top:50px;"> |
| <ul style="list-style-type:none; line-height:50px;"> |
| <li> |
| <telerik:RadComboBox ID="rcbSelection" runat="server" AutoPostBack="true"> |
| <Items> |
| <telerik:RadComboBoxItem Text="Show Button" Value="sb" /> |
| <telerik:RadComboBoxItem Text="Hide Button" Value="hb" /> |
| </Items> |
| </telerik:RadComboBox> |
| </li> |
| <li> |
| <asp:Label ID="lblButtonStatus" runat="server" Text="The Button that should post back is now visible." /> |
| </li> |
| <li> |
| <div style="width:500px; overflow:auto; border: solid 1px black;"> |
| <asp:Label ID="lblChangingText" runat="server" Text="This Text should Change" /> |
| </div> |
| </li> |
| <li> |
| <div> |
| <asp:Button ID="btnPostBackButton" runat="server" Text="Post Back Button" /> |
| <asp:Button ID="btnShouldDoAFullPostBack" runat="server" Text="Should Do A Full PostBack" /> |
| </div> |
| </li> |
| </ul> |
| </div> |
| <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> |
| <AjaxSettings> |
| <telerik:AjaxSetting AjaxControlID="rcbSelection" EventName="SelectedIndexChanged"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="lblButtonStatus" /> |
| <telerik:AjaxUpdatedControl ControlID="btnShouldDoAFullPostBack" /> |
| <telerik:AjaxUpdatedControl ControlID="lblChangingText" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| </AjaxSettings> |
| </telerik:RadAjaxManager> |
| protected void Page_Load(object sender, EventArgs e) |
| { |
| } |
| protected override void OnInit(EventArgs e) |
| { |
| base.OnInit(e); |
| this.rcbSelection.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(rcbSelection_SelectedIndexChanged); |
| this.btnShouldDoAFullPostBack.Click += new EventHandler(btnShouldDoAFullPostBack_Click); |
| this.btnPostBackButton.Click += new EventHandler(btnPostBackButton_Click); |
| } |
| void rcbSelection_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) |
| { |
| switch(e.Value.ToString().ToLower()) |
| { |
| case "sb": |
| lblButtonStatus.Text = "The Button that should post back is now visible."; |
| btnShouldDoAFullPostBack.Visible = true; |
| break; |
| case "hb": |
| lblButtonStatus.Text = "The Button that should post back is no longer visible."; |
| btnShouldDoAFullPostBack.Visible = false; |
| break; |
| } |
| } |
| void btnPostBackButton_Click(object sender, EventArgs e) |
| { |
| lblChangingText.Text = "You did a correct, full post back"; |
| lblChangingText.ForeColor = System.Drawing.Color.Black; |
| } |
| void btnShouldDoAFullPostBack_Click(object sender, EventArgs e) |
| { |
| lblChangingText.Text = "btnPostBackButton did an ajax request when clicked. It should have done a full post back. If you are seeing this then you've selected the drop down list after you pressed btnNonPostBack - which updates lblChangingText."; |
| lblChangingText.ForeColor = System.Drawing.Color.Red; |
| } |
| <form id="form1" runat="server"> |
| <asp:ScriptManager ID="ScriptManager1" runat="server"/> |
| <div> |
| <asp:Image ID="img_Intro" runat="server" ImageUrl="" style="vertical-align:middle;cursor:pointer;" /> |
| <telerik:RadToolTip ID="RadToolTip1" runat="server" RelativeTo="Element" TargetControlID="img_Intro" |
| ManualClose="true" Skin="Telerik"> |
| <div style="padding:5px;"> |
| <telerik:radeditor ID="RadEditor1" runat="server" Skin="Vista" ToolsFile="~/BasicTools.xml" Height="150px" EditModes="All" NewLineBr="false" /> |
| </div> |
| </telerik:RadToolTip> |
| </div> |
| </form> |

<
asp:Button ID="btnClose" CssClass="cmb_btnG" Text="<%$ CmbResources:eBAM,LEList_btnClose %>"
runat="server" OnClientClick="HideToolTip();" />
function
HideToolTip()
{
var tooltip = Telerik.Web.UI.RadToolTip.getCurrent();
if (tooltip)
{
tooltip.hide();
}
}
Hi Telerik team,
I need to create several RadGrid’s at run time according to the result of some queries, this means that I don’t have the exactly amount of RadGrids to be created on each pageload.
So at this point I am able to create the RadGrdis as needed, but I can’t make paging functionality works as expected.
I can surf only the first and second page, of my RadGrids, after that it appears that My RadGrids are not persisting on the server. I have try many options as enable the ViewState property, and others but without successful.
I am trying to follow this article to achieve my goal but I can not make, pages work as expected.
Based on this article http://www.telerik.com/help/aspnet/grid/grdprogrammaticcreation.html Section: Create Telerik RadGrid entirely in the code behind
Any comment will be very useful.
Thanks in advanced.
Ivan Ruiz
Cytrux Software