I would like to get the HTML rendering of an UltraWebGrid (more specifically, a custom subclass of one) as a string.
I have tried using Render(HTMLTextWriter), as well as the triad of RenderBeginTag, RenderControl, and RenderEndTag, but I always end up with a string that, when injected into a client-side popup, does not produce a usable grid. I can see some data, but not all of the client side widgets are available.
I'd really like to do this.
I'm guessing that I'm missing some client-side utility functions or elements/objects, but I don't really know where I would find them.
Could you provide a snippet of code to show how i would build the URL for the WebResource that only pulls down the js with the function igtbl_getGridById(gridId)?
Page.ClientScript.RegisterClientScriptInclude ???
Will that query string always remain constant, or is that generated based on some keys?
Hello,
Yes, this is expected since the grid registers the client-side scripts it uses using the Page.ClientScript.RegisterClientXXX set of methods, which effectively register the scripts needed by the grid in the OnPreRender stage of the page life-cycle. This is why they are not part of the HTML string produced by Render / RenderControl.
It gets even harder, since the scripts are embedded in the assembly (although you can certainly use external scrips as well) and look something like this:
<script src="/2008.3/WebResource.axd?d=JeY_tJ2PAOoZi_M7q9kOCKxLLW57HOzPwvlbTbIHKu78kYnLrryelOoCpIgaMse5UHalbD46CgWb-bafTQwrU0b6FVx6vlNab0_AnITzbSw1&t=633609934380996636" type="text/javascript"></script><script src="/2008.3/WebResource.axd?d=JeY_tJ2PAOoZi_M7q9kOCFmH_iOLh8K8tpCvoh668pXap4pZWfvUF05BgVvPY3Aq4cE3E4K415vjfTP0JaOVzrdZgcVLrVx3ciFNdrOcdxVQbIjiE7u4Cgsls3Mjs-vT0&t=633609934617706296" type="text/javascript"></script><script src="/2008.3/WebResource.axd?d=JeY_tJ2PAOoZi_M7q9kOCEPS8nJnBSvFTRVIZnPzo-vlBaNXk6JqxksozJqj9Da4wSslBKaJei_EMXgFa5A5d8Ftq08XPhnMTXB_rcvE0h2CUPLRH9yEzwVnV2LPPfWP0&t=633609934591144816" type="text/javascript"></script><script src="/2008.3/WebResource.axd?d=JeY_tJ2PAOoZi_M7q9kOCEPS8nJnBSvFTRVIZnPzo-vlBaNXk6JqxksozJqj9Da4wSslBKaJei_EMXgFa5A5d8Ftq08XPhnMTXB_rcvE0h3wyvOJQH6YV756xIpOv0kv0&t=633609934591144816" type="text/javascript"></script>To make it even harder, the grid uses some scripts and some not bad on the settings of the grid. So it is really very very hard to determine which scrips you need. Basically, you can create a grid and see which scripts it produces and the manually include them in the header. Alternatively, you can create custom control inheriting from UltraWebGrid and make sure it passed the OnPreRender stage of the page lifecycle as well.