Thanks David -
That sounds like a sensible idea. I tried it using the following code:
protected override object SaveViewState() {
DynamicFunction f = this.ScriptTemplateControl.GetFunction("ScriptSaveViewState");
if (f == null) {
return base.SaveViewState();
} else {
return this.ScriptTemplateControl.CallFunction(f);
}
}
I structured it this way, rather than using your definition, because this makes the code more closely match what it would look like if we were really overriding the method.
Then the IronPython code for ScriptSaveViewState is:
def ScriptSaveViewState():
state = {}
state["baseState"] = ScriptPage.SaveViewState(page)
state["document"] = pickle.dumps(page.document)
state["currentPage"] = pickle.dumps(page.currentPage)
state["editing"] = page.editing
return state
It wraps the base class's viewstate in a dictionary with my page's extra state; I'm doing the super call using the usual Python idiom, being careful to directly call SaveViewState on ScriptPage rather than CustomScriptPage (which would lead to infinite recursion).
For some reason, when this executes I do get an infinite recursion, and the dev web server blows up. Debugging I can see that the ScriptPage.SaveViewState(page) line is for some reason calling CustomScriptPage.SaveViewState instead - essentially it looks like it's doing a normal method dispatch on page (ie page.SaveViewState, which is CustomScriptPage.SaveViewState) when it should be using the specific method ScriptPage.SaveViewState. Do you know why this might be?
Thanks for your help,
Christian