Nov 04, 2009, 9:58 AM
Problem adding controls dynamically to a page. Refreshing lasts forever.
Hi,
I am new to this and trying to figure out how to add controls dynamically to a page. I wrote a test case but that does not seems to be working. I get a Refreshing... and Firefox Error console shows errors.
All I need is the ability to add controls at runtime. This is for a custom control to render contents based on certain values.
I am new to this and trying to figure out how to add controls dynamically to a page. I wrote a test case but that does not seems to be working. I get a Refreshing... and Firefox Error console shows errors.
using System;
using System.Web;
using Coolite.Ext.Web;
public partial class _Default : System.Web.UI.Page
{
Coolite.Ext.Web.Panel p = null;
protected void Page_Load(object sender, EventArgs e)
{
Coolite.Ext.Web.ScriptManager sm = new Coolite.Ext.Web.ScriptManager();
Controls.Add(sm);
p = new Coolite.Ext.Web.Panel();
Coolite.Ext.Web.Button myButton = new Coolite.Ext.Web.Button();
p.Controls.Add(myButton);
Controls.Add(p);
myButton.AjaxEvents.Click.Event += new ComponentAjaxEvent.AjaxEventHandler(Click_Event);
sm.AddUpdatePanelToRefresh(p);
}
void Click_Event(object sender, AjaxEventArgs e)
{
Coolite.Ext.Web.Button myButton = (Coolite.Ext.Web.Button)sender;
myButton.Text = "You have clicked me!";
Coolite.Ext.Web.Label l = new Coolite.Ext.Web.Label("Add this label here!");
p.Add(l);
p.Reload();
}
}
Any clue how to get this to work?All I need is the ability to add controls at runtime. This is for a custom control to render contents based on certain values.