Friday, July 11, 2008

Ajax Databind – javascript error “unknown runtime error”

I had this error a few minutes ago. It was the weirdest thing. On a Save button (linkbutton) I had a gridview repopulated using Ajax. The Save linkbutton was also added as a trigger for the Ajax’s UpdatePanel. The save went well, saved in the database, but when it came to refresh the gridview, this javascript error popped up.

The fix was move the stuff around. Scriptmanager, UpdatePanel, ObjectDataSource … all of them inside the form … Anyways … if you have this error, you don’t necessarily have a big problem, you just need to figure out what did you put in the wrong place.





< form id="form1" runat="server">

< ajax:ScriptManager runat="server" ID="ScriptManager1" EnablePartialRendering="true">
< Services>
< ajax:ServiceReference Path="../Include/WebService.asmx" InlineScript="true" />
< /Services>
< /ajax:ScriptManager>
< ajax:UpdatePanel ID="up2" runat="server">
< ContentTemplate>
< asp:GridView>
...
< /asp:GridView>
< /ContentTemplate>
< Triggers>
< ajax:AsyncPostBackTrigger ControlID="lbnSave" EventName="Click" />
< /Triggers>
< /ajax:UpdatePanel>

< asp:ObjectDataSource ID="ods" ...
< SelectParameters>
< asp:QueryStringParameter ...
< /SelectParameters>
< /asp:ObjectDataSource>

< /form>






see ya

No comments: