This is a migrated thread and some comments may be shown as answers.

[Solved] Problem switching to prometheus (AjaxManager)

3 Answers 250 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
paulo.galão
Top achievements
Rank 1
paulo.galão asked on 02 Aug 2007, 01:57 PM

Hi there,

I’m trying to figure out how to use Prometheus and got stuck with the problem I try to describe below.

As you can see I am instantiating two ‘BaseControl’ user controls in the page.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Src="BaseControl.ascx" TagName="BaseControl" TagPrefix="uc1" %>

<%@ Register Assembly="RadAjax.Net2" Namespace="Telerik.WebControls" TagPrefix="telerik_old" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik_prometheus" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

<form id="form1" runat="server">

<asp:ScriptManager ID="SriptManager1" runat="server">

</asp:ScriptManager>

<telerik_old:RadAjaxManager ID="RadAjaxManager1" runat="server">

</telerik_old:RadAjaxManager>

<div>

<uc1:BaseControl ID="BaseControl1" runat="server" />

<uc1:BaseControl ID="BaseControl2" runat="server" />

</div>

</form>

</body>

</html>

The user control is as follows:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="BaseControl.ascx.cs" Inherits="BaseControl" %>

<asp:Panel ID="OuterPanel" runat="server" Height="100px">

<asp:Panel ID="InnerPanel" Visible="false" runat="server" EnableViewState="false">

inner

</asp:Panel>

outer

</asp:Panel>

<script type="text/javascript">

function <%= this.ClientID %>_doAjaxRequest()

{

<%= AjaxManager.ClientID %>.AjaxRequestWithTarget("<%= this.UniqueID %>", "iNIT");

document.getElementById('<%= OuterPanel.ClientID %>').style.backgroundColor = '#0000ff';

}

setTimeout('<%= this.ClientID %>_doAjaxRequest()', 200);

</script>

And…

using System;

using System.Web;

using System.Web.UI;

using System.Threading;

//using Telerik.Web.UI;

using Telerik.WebControls;

public partial class BaseControl : UserControl, IPostBackEventHandler

{

protected override void CreateChildControls()

{

base.CreateChildControls();

}

protected void Page_Load(object sender, EventArgs e)

{

AjaxManager.AjaxSettings.AddAjaxSetting(this, OuterPanel, null );

AjaxManager.AjaxSettings.AddAjaxSetting(OuterPanel, OuterPanel, null);

}

public virtual void RefreshData()

{

InnerPanel.Visible = true;

Thread.Sleep(2000);

}

public void RaisePostBackEvent(string eventArgument)

{

RefreshData();

}

public RadAjaxManager AjaxManager

{

get

{

return ((RadAjaxManager)Page.FindControl("RadAjaxManager1"));

}

}

}

This works great with RadAjax – which means that the content for ‘InnerPanel’ is initally invisible and then ‘loaded’ via AjaxRequest.

The problem happens when I replace:

1)

using Telerik.WebControls;

with

using Telerik.Web.UI; (in BaseControl.ascx.cs)

2)

<telerik_old:RadAjaxManager ID="RadAjaxManager1" runat="server">

</telerik_old:RadAjaxManager>

with

<telerik_prometheus:RadAjaxManager ID="RadAjaxManager1" runat="server">

</telerik_prometheus:RadAjaxManager>

(in default.aspx)

After these two changes I am using Prometheus’ AjaxManager and the app doesn’t work anymore. I start getting the following error:

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

The question is: what am I missing here? Shouldn’t it work?

Any advice?

Thanks,

Paulo

3 Answers, 1 is accepted

Sort by
0
David Silveria
Top achievements
Rank 1
answered on 02 Aug 2007, 02:03 PM
Try removing the runat=server from your head tag. Although you do not have code blocks in it, this has been the reason for problems I had before.
0
paulo.galão
Top achievements
Rank 1
answered on 02 Aug 2007, 02:18 PM
Hi David,
Thanks for your reply but the problem persists.
Should I try something else?
Thanks.
0
Konstantin Petkov
Telerik team
answered on 04 Aug 2007, 01:51 PM
Hi paulo.galão,

You need to wrap your script inside telerik:RadCodeBlock control. Please, read step 6 at "Migration from previous versions" help article for more info.

All the best,
Konstantin Petkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Ajax
Asked by
paulo.galão
Top achievements
Rank 1
Answers by
David Silveria
Top achievements
Rank 1
paulo.galão
Top achievements
Rank 1
Konstantin Petkov
Telerik team
Share this question
or