[CLOSED] Generate Script from Aspx

  1. #1

    [CLOSED] Generate Script from Aspx

    Hi,
    Is there anyway I can generate script of Aspx file through a method for the components declared in page. I want the script that is generated by Ext.net as init script for the page.
    Last edited by fabricio.murta; Mar 10, 2017 at 7:25 PM.
  2. #2
    Hello @amitpareek!

    I'm not sure I understand your question well. The only bell ringing here is: set in your resource manager the setting: ScriptMode="Inline". This also works in Web.config's extnet tag, just lower camel case initScriptMode="Inline".

    Inline has been the default setting until Ext.NET 2. From Ext.NET 3 onwards, Linked is the default.

    I hope this helps. If that's not what you need, please elaborate on the question so we can better understand your needs.
    Fabrício Murta
    Developer & Support Expert
  3. #3
    This is not what I want. Lemme explain.

    During page cycle, is there anywhere I can call a function which will give me content of "extnet-init-js" in a variable.

    I tried resourcemanage.BuildAll(); but that has anchor tags for controls which are filled later in page lifecycle. I want the whole data of init script.

    So for eg. I should be able to do something like this.

    string extCode = Page.GenerateExtScripts();
  4. #4
    Hello @amitpareek!

    During page load, and only during the first page load (or page_init) the commands list is still being built, so there's no way to get them with accuracy.

    At that time, to get the script for components of the page, you have to use the component's ToConfig() or ToScript() methods. For example, if you envelop all components of your page in a ViewPort, and give the viewport and ID, you can just get the script of the viewport that it will bring in all components inside it.

    Of course, they won't contain dynamic, pre-and-post client init code like the page's init. But again, these parts -- if present -- are added by code behind calls as the Page_Load() event method is executed.

    A similar, client-side approach for this is possible, though, using ResourceManager's App AutoInit feature. Check it out here, maybe it can fulfill your needs: Call init script manually.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  5. #5
    I like the autoinit feature. However, the data is already sent to the client side and then its just a matter of executing initfunction.

    I was wondering if I could get init code on page unload event. Or if I could type something like 'default.aspx.axd" to get its JS code.
  6. #6
    One of the primary reasons to have this is to take ext.net app offline. To compile, I would just call this .axd file to get the script and use it offline. I know there are manual ways to do it, I was just wondering if it could be simple.
  7. #7
    Hello!

    While webforms constrained, one idea is using an approach similar to the component loader examples. Except that instead of using a loader to handle the loading for you, you will get the returned config block to use as you feel fit.

    This is one example to start with. Look at its neighboring examples for different approaches/scenarios:
    - Component Loader - Direct Method

    And if you are on MVC, take a look on the dynamic partial rendering examples. They are pretty much the same but on the MVC approach for building partial views. An example to start with would be this:
    - Dynamic Partial Rendering - Partial Items

    I hope this helps!

    Notice that uncoupling the code might bring you issues if you use direct methods/events simply cause (as it sounds) you want to run the page without the ASP.NET layer, which means no server-side AJAX (or anything server-sided) should be expected to work from your statically-run script.

    It would also be laid on your shoulders the job of including the necessary script files and resources that are imbued on Ext.NET DLL file and only available from the ASP.NET layer. All this is done in a stage after all ASP.NET page lifecycle (so Ext.NET can ensure all necessary information is gathered to include the resources) has finished and composed dynamically as the server is about to reply with the page code.
    Fabrício Murta
    Developer & Support Expert
  8. #8
    Hello @amitpareek!

    It's been some days since we replied here and still no feedback from you. Were the directions above helpful or do you still need help with this issue?

    If you don't post a follow-up in 7+ days, we might just mark this thread as closed, but it won't prevent you from posting once you are able to, even after marked as closed.
    Fabrício Murta
    Developer & Support Expert
  9. #9
    you can close this for now. The purpose was attended to by other means. However, I may revive this thread in future if that's okay.
  10. #10
    Thanks for the feedback, @amitpareek! Yes, that's fine to open this thread whenever you need it! We may ask to open another thread if it is too old (months, maybe) or if the actual issue when reopening is not exactly in the same subject.
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 2
    Last Post: Nov 15, 2012, 12:52 AM
  2. Replies: 7
    Last Post: Jul 31, 2012, 8:31 PM
  3. Replies: 4
    Last Post: May 14, 2012, 10:22 AM
  4. Replies: 0
    Last Post: Aug 05, 2009, 9:48 AM
  5. AjaxEvent from a child.aspx to a parent.aspx
    By egodoy in forum 1.x Help
    Replies: 2
    Last Post: Mar 23, 2009, 12:52 PM

Posting Permissions