L
Louis Somers
Hi,
I am having an issue with replacing my home-made button control with other (standard) buttons.
In the Click event of the buttons I dynamically add some controls to this.Form.Controls. With my old
buttoncontrol this worked fine, however replacing it with a standard Button (or also an ASPxButton
from Developer Express) causes the following behavior:
The dynamically added controls do not show up after the page is rendered. If I recursively plot out
the control tree to the trace, I do see the new controls in their proper place (same behavior with
both kinds of button), however, in the end they do not get rendered to the client.
The moment at which the event fires also is identical with both buttons. Looking at the trace, both
kinds of button fire their event at the same place:
....
aspx.page: Begin Raise PostBackEvent
-> Click event here
aspx.page: End Raise PostBackEvent
....
The implementation of my old (to be replaced) button is based on Control, implementing
IPostBackEventHandler. In the constructor it creates a table with one row containing two cells (in
the left an image is placed, in the right some text), and adds this table to it's Controls
collection. The most relevant code is shown below (TR is the TableRow):
-------------------
protected override void Render(HtmlTextWriter writer) {
TR.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(this, "Click", true) +
";return false;";
base.Render(writer);
}
public event EventHandler Click;
public void RaisePostBackEvent(string eventArgument) {
if (Click != null) {
Click(this, new EventArgs());
}
}
-------------------
One last detail: the buttons are placed on a control that inherits from UpdatePanel (UpdateMode=always).
So, why does my custom button work (the dynamically created controls show up) but when replaced with
a normal button not?
Any help appreciated,
Louis
I am having an issue with replacing my home-made button control with other (standard) buttons.
In the Click event of the buttons I dynamically add some controls to this.Form.Controls. With my old
buttoncontrol this worked fine, however replacing it with a standard Button (or also an ASPxButton
from Developer Express) causes the following behavior:
The dynamically added controls do not show up after the page is rendered. If I recursively plot out
the control tree to the trace, I do see the new controls in their proper place (same behavior with
both kinds of button), however, in the end they do not get rendered to the client.
The moment at which the event fires also is identical with both buttons. Looking at the trace, both
kinds of button fire their event at the same place:
....
aspx.page: Begin Raise PostBackEvent
-> Click event here
aspx.page: End Raise PostBackEvent
....
The implementation of my old (to be replaced) button is based on Control, implementing
IPostBackEventHandler. In the constructor it creates a table with one row containing two cells (in
the left an image is placed, in the right some text), and adds this table to it's Controls
collection. The most relevant code is shown below (TR is the TableRow):
-------------------
protected override void Render(HtmlTextWriter writer) {
TR.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(this, "Click", true) +
";return false;";
base.Render(writer);
}
public event EventHandler Click;
public void RaisePostBackEvent(string eventArgument) {
if (Click != null) {
Click(this, new EventArgs());
}
}
-------------------
One last detail: the buttons are placed on a control that inherits from UpdatePanel (UpdateMode=always).
So, why does my custom button work (the dynamically created controls show up) but when replaced with
a normal button not?
Any help appreciated,
Louis