L
Louis Somers
Hi,
I have a simple ASPX page called Default.aspx. On it (nested within allot of other stuff) I have a
custom control which inherits from TableRow and implements IPostBackEventHandler.
This custom control hast the following code:
---------
protected override void OnInit(EventArgs e) {
base.OnInit(e);
string PostBackRef = Page.ClientScript.GetPostBackEventReference(this, Item.Identificatie);
Attributes.Add("onclick", PostBackRef);
}
public event MyEvent OnClicked;
public void RaisePostBackEvent(string eventArgument) {
if (OnClicked != null) {
OnClicked(this);
return;
}
}
----------
At first this seemed to work fine. The event is triggered correctly when the user clicks the table
row. However, in the eventhandler I create allot of new controls which are dynamically added to the
page. These are rendered correctly but are for some reason not persistent.
To figure out why, I override some methods in the default.aspx page and plot out the entire control
tree to the trace. I did this on:
LoadViewState(object savedState)
OnPreRender(EventArgs e)
SaveViewState()
and also in the event handler of my custom TableRow.
To my astonishment I found that SaveViewState is being called before the event is triggered!
Can someone please explain what I am doing wrong and why?
Thanks in advance,
Louis
I have a simple ASPX page called Default.aspx. On it (nested within allot of other stuff) I have a
custom control which inherits from TableRow and implements IPostBackEventHandler.
This custom control hast the following code:
---------
protected override void OnInit(EventArgs e) {
base.OnInit(e);
string PostBackRef = Page.ClientScript.GetPostBackEventReference(this, Item.Identificatie);
Attributes.Add("onclick", PostBackRef);
}
public event MyEvent OnClicked;
public void RaisePostBackEvent(string eventArgument) {
if (OnClicked != null) {
OnClicked(this);
return;
}
}
----------
At first this seemed to work fine. The event is triggered correctly when the user clicks the table
row. However, in the eventhandler I create allot of new controls which are dynamically added to the
page. These are rendered correctly but are for some reason not persistent.
To figure out why, I override some methods in the default.aspx page and plot out the entire control
tree to the trace. I did this on:
LoadViewState(object savedState)
OnPreRender(EventArgs e)
SaveViewState()
and also in the event handler of my custom TableRow.
To my astonishment I found that SaveViewState is being called before the event is triggered!
Can someone please explain what I am doing wrong and why?
Thanks in advance,
Louis