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