
I am using Normal telerik radgrid bind.
on OnLoad Event i called load grid functionality.
private void OnLoad()
{
uxUserList.DataSource = Model.UsersModelList;
uxUserList.DataBind();
}
it's working fine.
but when i enabled AllowPaging="true" i get the following error.
i am using RadScriptManager on My master page. and Perticular code block is
called inside a user control.
Server Error in '/Baker.IssueTrackingSystem.Web' Application.
Script controls may not be registered after PreRender.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Script controls may not be registered after PreRender.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
Stack Trace:
|
11 Answers, 1 is accepted
Looking at the call stack you have pasted, it seems that you are using WebFormsMVP. Therefore, I suspect that the cause for the error you are getting is the way MvpUserControl is implemented. As you may know the class exposes an AutoDataBind property, which by default will cause a call to DataBind on PreRenderComplete event. However, this will eventually recreate all databound controls too late in the page's lifecycle causing IScriptControl implementers to thrown the mentioned exception. Thus, could you set AutoDataBind property to false (inside UserControl's constructor) and see if this makes any difference in the observed behavior.
Greetings,
Rosen
the Telerik team

I am using MVP framework as explained on http://webformsmvp.com/ and tried to data bind a RadGrid (Q2.2011) and got the same 'script controls may not be registered before prerender' error as described by Joe Joseph.
After creating a constructor for my code behind class and setting the boolean AutoDataBind to false I still got the same error.
On the verge of pulling my hair out I noticed that the method Register<T> in the PageViewHost class was called not once (as I was expecting since there was only one UserControl in my project at that point) but twice.
And then it dawned to me; the Page which was carying the UserControl was using the MvpPage implementation, functioning as a container and thus calling the Register<T> method (and data binding) all of it's child controls.
Anyhow, Rosen, thank you once again for your help.
Excellent support from Telerik!

I have the same problem myself.
Using MVP framework where one user control has another one inside and I get this same error.
Hope this does not means that I have to combine user controls in one big pile of code :).

No, you do not have to combine all your user controls in to one big pile of code. Fortunately :-)
You will need to set the property AutoDataBind to false in both MvpUserControl.cs and MvpPage.cs. These two classes can be found (in the original project) in the WebFormsMvp project in the map Web.
Hope this helps.
If you have any more questions, feel free to ask!

Well I did what you said, and now I don't have telerik script error on prerender, but I nothing shows in my radgrid :(.
My scenario is : one big Usercontrol with searchbox and textbox and 5 others usercontrols.
Each of these controls has a presenter, model and radgrid + mvp:PageDataSource.
Is there any way to bind this thing manually, with having AutoDataBind=true?
Thanx,
-Goran

Are you using the OnNeedDataSource event on your RadGrid?
That should do the trick.
If not, could you post you're code / project so I could take a closer look?

I'v tried with OnNeedDataSource event and while it gets the data from model it does not react when I change the main model(which other model use as a parent container).
There is not much code to post since I am getting data from a web service and use only one telerik databound control and one datasource control in each user control.
It works well with normal Mvp wiring, all events are firing properly with no need for code behind.
I think that changing the RadGrid binding kind of breaks up the fine logic of MVP pattern.
On the other hand, I have to use Radgrid because of UI complexity that I have to develop so I will have to bind this thing manually somehow.
Thanks for the help.
-Goran


Yes, back then I was succesful in getting rid of this error. Could you show me what your setup and/or post some code?
Kind regards,
Rob

Thanks for your quick response! I was able to figure it out as well by reading and reading and reading your postL
'On the verge of pulling my hair out I noticed that the method Register<T> in the PageViewHost class was called not once (as I was expecting since there was only one UserControl in my project at that point) but twice.
And then it dawned to me; the Page which was carying the UserControl was using the MvpPage implementation, functioning as a container and thus calling the Register<T> method (and data binding) all of it's child controls.'
I turned off AutoDataBind on the right place and it's working now.
Thanks again!
Gus

base.OnPreRender(e);wherever overrding method OnPreRender()protected override void OnPreRender(EventArgs e) { base.OnPreRender(e);
................................
................................
}
Hello All,
I am also facing same issue, below is my stack trace, please help... thank you !!
Stack Trace:
|
Hi Sky,
Are you using the OnNeedDataSource event on your RadGrid or you are calling its DataBind method? If the second is true, try moving the datasource-setting logic to the OnNeedDataSource event and see how it goes?