Hi.
We've been struggling a lot of hours now with this problem.
The problem outline goes like this:
We've got an aspx page which in turn loads a usercontrol (inherited from the EO.Web.Dialog control) which displays a dialog when added to the page. - So far so good.
Next, in this custom usercontrol that inherits from the Dialog control, I'm adding code to create controls dynamically depending different factors.
Simplified sample code from the overrided OnLoad method:
Quote:
Button[] names;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
base.SetProperties();
System.Collections.Generic.List<Section> forumSections = Forums.GetForumsByForumGroupID(this.sectionID);
names= new Button[forumSections.Count];
for (int ii = 0; ii != forumSections.Count; ii++)
{
names[ii] = new Button();
names[ii].Text = forumSections[ii].Name;
names[ii].Click += new EventHandler(names_Click);
this.Controls.Add(names[ii]);
}
}
(I've tried the same code in the Load method, and in the Render method)
This is my current overrided Rendermethod, simplified:
Quote:
protected override void Render(HtmlTextWriter writer)
{
for (int ii = 0; ii != lbCategoryNames.Length; ii++)
{
names[ii].RenderControl(writer);
writer.Write("<br/>");
}
}
So far, so good. The controls render when the Render method runs the code and the Buttons are displayed in my dialog accordingly.
However, the registered event occuring in the first codesnippet, sample below, doesn't seem to connect to the eventhandler..
Quote:
names[ii].Click += new EventHandler(names_Click);
When I click the button nothing happens, at all.
We've been struggling with this issue for quite some time, and no matter what we do, there's always a new problem when using a similar approach.
When I set a debugger breakpoint inside the names_Click method, I can see that the code never gets there. Even though I've bound all the buttons to the eventhandler I can't seem to get it to run the method when the button is clicked.
Could we please get some assistance here, or are we out on deep water?
Are the dialogs made to be able to contain dynamic controls (and their events)