1
votes

Please, I am new to webparts and I need help!!

I have a custom web part that I created. I added MS Ajax to it using an UpdatePanel which works fine. I add all my controls to the CreateChildControls method. As soon as I add a UpdateProgress control my page breaks with the following error:

Script controls may not be registered before PreRender

I do not use the OnPreRender event as what other posts suggest. Please, if anyone can give me advice it will be very much appreciated.

Thanks

2

2 Answers

2
votes

I encountered similar problem before, try to call EnsureChildControls method inside your on init method override. It should be called by system automatically, but sharepoint likes to forget about it from time to time.

Like this:

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        EnsureChildControls();
    }
1
votes

You might have forgotten to call the base method of an overrided event, which is not necessarily the OnPreRender event.

Check if the OnInit or OnLoad events are calling their base.On[...] method, e.g.:

protected override void OnLoad(EventArgs eventArgs)
{
    base.OnLoad(eventArgs);

    // your code...
}