I have a ASP.NET page that contains both javascript and ASP.NET user controls. When a postback is executed, I use the RaisePostBackEvent method to determine which method should be called. That way, it’s possible to trigger a postback via javascript. For example, I load a User Control via a postback that was triggered via javascript. However, the events of such a user control can’t be raised via postback anymore, because the RaisePostBackEvent method is called, rather than de default postback behaviour. So how can I call the default postback behaviour on a user control, from within the RaisePostBackEvent method?
public void RaisePostBackEvent (string eventArgument) {
string eventTarget = Request ["__EVENTTARGET"];
if (eventTarget == UniqueID) {
eventArgument = Request ["__EVENTARGUMENT"];
Action action = JsonConvert.DeserializeObject<Action>(eventArgument);
if (action.name == "display") Display(action.argument);
else if (action.name == "edit") Edit(action.edit);
}
else {
// Control control = GetPostBackControl(this.Page);
// !!! Raise the postback event on the control.
}
}
I had this statement in the
OnInitevent method of the user control containing the javascript:When this statement is removed, it works.