[OPEN] [#1819] Migration from legacy code

  1. #1

    [OPEN] [#1819] Migration from legacy code

    Hello

    I'm not comming with example to reproduce, I'm more looking for general question to be answered or direction to investigate

    We have the project in legacy Ext.Net ( without .Net core) and we are thinking to migrate to Classic one.
    we have relativelly lot of ascx code in user controls, that are using LoadControl in order to be loaded into the memory, and then ToCOnfig method of the ComponentLoader in order to generate js for example :

    UserControl ctrl = (UserControl)LoadControl(virtualPath);
    var jsConfig = ComponentLoader.ToConfig(ctrl, false);
    In other words we are "generating" JSON object config from the ascx files
    (as ascx files is much easier to write, there is full intelisences etc)

    Is it possible to have some kind of simila approach in Ext.NET 7 (so somehow take cshtml file and generate javascript from it?)
    or little bit more in general - how to write single page application using ext.net 7 (idea is that all the javascript files - including forms and anything that participate on rendering layout, excluding data, will be downloaded on one requests, and later on app will just dowload pure data as user walks throught the app)

    Thanks
    Louise
  2. #2
    Hello @Ibrohan, and welcome to Ext.NET forums!

    I believe what's closes to the approach you need would be the so-called Partial Views.

    Basically it does what you want: you create a "partial page" with just the components belonging to that segment, and they are (internally) communicated as JavaScript commands to draw the components to the main page.

    This is still work in progress for Ext.NET 7 and we don't really have something "in stone" regarding partial views in Ext.NET 7. It will exist, that's a given, but we can't yet tell how exactly it will look like in code.

    If you are wondering what's this Partial View thing is about, we already have support for it in Ext.NET 5 MVC and you can browse several examples exploring the feature in our MVC Examples Explorer:

    - Calendar > Overview > Basic
    - Calendar > Overview > Remote_Data
    - Dynamic > Partial_Rendering > Add_Tab
    - Dynamic > Partial_Rendering > ASPX_Engine
    - Dynamic > Partial_Rendering > Partial_Content
    - Dynamic > Partial_Rendering > Partial_Items
    - Dynamic > Partial_Rendering > Render_as_Config
    - Dynamic > Partial_Rendering > Window
    - Items > ASPX_Engine
    - Miscellaneous > Factory > Basic

    Maybe you should start by the ASPX Engine one, as it is closer to what you use now, and then (as ASPX Engine is not a thing in ASP.NET Core) move to the others that rely on the Razor Syntax.

    Something else that may open another range of options for you is -- in regards of the "ASCX" part of the concept -- the new Tag Helpers concept. It is not really a partial view/content, but may allow you to draw a custom component the way you need it and simply add (and reuse) it to your pages however you need. And that's part of the new technology applied to Ext.NET 7, and what we could do to best resemble our old WebForms markup in the modern environment.

    Hope these shed light in the possibilities open for your migration!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    ok thanks

    just for partial views, is there a way how to render more then one "view" to the javascript?
  4. #4
    Hello @lbrohan!

    I am not sure I understand your question, the whole idea behind partial views is to be able to compose a page over several views, not just one. Can you elaborate on it?

    If that was your question, the Dynamic > Partial_Rendering > Partial_Items example is probably a good proof of that.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  5. #5
    Yes I think I'm very close now

    The example I was looking for is actually this one : https://mvc5.ext.net/#/Dynamic_Parti...der_as_Config/

    The only what I want is to render more then one component

    so instead of

    return new Ext.Net.MVC.PartialViewResult
                {
                    ViewName = "Component",
                    RenderMode = RenderMode.Config
                };
    specify something like
    return new Ext.Net.MVC.PartialViewResult
                {
                    ViewName = "Component1, Component2",
                    RenderMode = RenderMode.Config
                };

    is it possible?
  6. #6
    Hello @lbrohan!

    Just to be clear, notice this will not necessarily work in Ext.NET 7 the exact way it does in Ext.NET 5 MVC, for a number of reasons we just can't foresee at this point. But there will surely be similar approaches to the same end in the new version.

    One partial view can return as many components as it contais.

    One partial view though, is one partial view, it cannot return two different views.

    But again, you can just reference the two individual partial views to one partial view, or to the main page.

    What I want to tell here is that you will just have two partial view bodies with the code block you pointed. So each with its own:

    first

    return new Ext.Net.MVC.PartialViewResult
    {
        ViewName = "Component1",
        RenderMode = RenderMode.Config
    };
    second

    return new Ext.Net.MVC.PartialViewResult
    {
        ViewName = "Component2",
        RenderMode = RenderMode.Config
    };
    Then you can have a third

    return new Ext.Net.MVC.PartialViewResult
    {
        ViewName = "Component1AndComponent2",
        RenderMode = RenderMode.Config
    };
    The change though, would go in the partial view itself.

    bottomline

    If your only concern is whether it would be possible or not, the answer is yes, it will be possible, just not exactly the way you suggested, because one partial view is limited to the view it represents.

    Even in a same method it will probably be possible to specify two views, but it would take further code.

    We still don't have a partial view support formally implemented in Ext.NET 7.

    I have just logged and issue in GitHub to request formal Partial Views support and info to Ext.NET 7. Issue is #1819. We will post an update here as soon as we have news on Partial View support to Ext.NET 7.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  7. #7
    Ok thanks

    very helpfull info

    Feel free to close this thread

Similar Threads

  1. Upgrading to 4.1 with support for legacy 1.x
    By rmelancon in forum 4.x Help
    Replies: 15
    Last Post: Dec 08, 2016, 12:07 PM
  2. Replies: 7
    Last Post: Jan 19, 2016, 7:54 AM
  3. [CLOSED] Migration of MultiSelect loading in code behind
    By rmelancon in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 01, 2013, 4:42 PM
  4. [OPEN] [#26] Grid panel grouping and sorting from code-behind
    By Manni in forum 2.x Legacy Premium Help
    Replies: 9
    Last Post: Dec 12, 2012, 10:19 PM
  5. Replies: 2
    Last Post: Sep 12, 2008, 10:38 AM

Posting Permissions