G
Guest
1) Start a new web application in Visual Studio
2) Drop a CheckBox onto the form and set its AutoPostBack to TRUE
3) In the codebehind, override the RaisePostBackEvent event with:
protected override void RaisePostBackEvent(
IPostBackEventHandler sourceControl, string eventArgument) {
base.RaisePostBackEvent(sourceControl, eventArgument);
}
4) Set a breakpoint in the event handler
5) Run the app and click the CheckBox
The form posts back, but the event handler is not raised. Why? What am I
missing?
What I am really trying to do is capture when the user clicks on a table row
and process information from the row that is clicked. The table rows are
being created dynamically, and I can cause a postback by adding the onclick
Attribute to each <TR> row by using:
row.Attributes.Add("onclick", GetPostBackClientEvent(table,
rowCount.ToString());
But the RaisePostBackEvent does not fire. The above example with a CheckBox
is simpler to demonstrate and I assume does not fire for the same reason I am
missing.
I am trying to capture a click event on a server control that does not have
an click method. I am not creating a custom control but overriding the
RaisePostBackEvent on the Page. Is this possible?
Thanks for any help.
2) Drop a CheckBox onto the form and set its AutoPostBack to TRUE
3) In the codebehind, override the RaisePostBackEvent event with:
protected override void RaisePostBackEvent(
IPostBackEventHandler sourceControl, string eventArgument) {
base.RaisePostBackEvent(sourceControl, eventArgument);
}
4) Set a breakpoint in the event handler
5) Run the app and click the CheckBox
The form posts back, but the event handler is not raised. Why? What am I
missing?
What I am really trying to do is capture when the user clicks on a table row
and process information from the row that is clicked. The table rows are
being created dynamically, and I can cause a postback by adding the onclick
Attribute to each <TR> row by using:
row.Attributes.Add("onclick", GetPostBackClientEvent(table,
rowCount.ToString());
But the RaisePostBackEvent does not fire. The above example with a CheckBox
is simpler to demonstrate and I assume does not fire for the same reason I am
missing.
I am trying to capture a click event on a server control that does not have
an click method. I am not creating a custom control but overriding the
RaisePostBackEvent on the Page. Is this possible?
Thanks for any help.