I have a WebGrid in my Razor View. It's performing its task well like paging and sorting. Now I need to make the paging and sorting in ajax call, so I assigned it an ajaxUpdateContainerId.
Now When grid.GetHtml()
method is called, it's rendering its script first and then the table Html. I have the jquery loaded at the end of the page(Script Section in _Layout view).
Due to this, Ajax functions are useless as it can't find JQuery.
I have a workaround for this: I copy the rendered script from page source and paste it in the script section of the view and it works but this still leaves the error in the console so I believe it's not a proper solution.
Another workaround is to reference jquery before calling grid.GetHtml()
method but that will leave two references to the same javascript library. Again bad design.
So is there any way we can force WebGrid to render the script in script section as it should logically behave.