[CLOSED] Custom control and Resources property

  1. #1

    [CLOSED] Custom control and Resources property

    I created a custom control in my web project. The control is a panel that renders a form and a grid. The control has its own javascript and css files located in the web project. I have two questions in regards to setting up resources for this control.

    1. Is there a way for the control to specify to always load from file even though the global ResourceManager is not set to load from file? This is important because I do not intend to embed the javascript and css files for this control as embedded dll resources since it's inside my web project. I also want to be able to change the javascript file and refresh the browser to see the changes without having to rebuild the web project.

    2. How do I add resources for gridpanel to the Resources property? If someone drops this control on a page, I want both my custom resources to be loaded plus the GridPanel resources.
    Last edited by Daniil; Sep 18, 2012 at 12:26 PM. Reason: [CLOSED]
  2. #2
    Hi @jchau,

    Quote Originally Posted by jchau View Post
    1. Is there a way for the control to specify to always load from file even though the global ResourceManager is not set to load from file? This is important because I do not intend to embed the javascript and css files for this control as embedded dll resources since it's inside my web project. I also want to be able to change the javascript file and refresh the browser to see the changes without having to rebuild the web project.
    Unfortunately, there is no solution in Ext.NET v1.

    But in Ext.NET if you will leave the embeddedPath parameter empty, the common path will be used.

    Example
    protected override List<ResourceItem> Resources
    {
        get
        {
            var res = base.Resources;
    
            res.Capacity += 1;
            res.Add(new ClientScriptItem("", "~/resources/js/test.js"));
    
            return res;
        }
    }
    In Ext.NET v1 it causes the Exception which says that embedded path cannot be empty.

    It is all with default RenderScripts="Embedded" of ResourceManager.

    You can override the ResourceManager RegisterScripts method to achieve your requirement it Ext.NET v1. Here how it looks now.

    RegisterScripts
    internal void RegisterScripts(List<ClientScriptItem> scripts, ResourceManager rm)
    {
        rm = rm ?? this.ResourceManager;
    
        foreach (ClientScriptItem item in scripts)
        {
            if (rm.RenderScripts == ResourceLocationType.Embedded || rm.RenderScripts == ResourceLocationType.CacheFly)
            {
                if (rm.ScriptMode == ScriptMode.Release || item.PathEmbeddedDebug.IsEmpty())
                {
                    rm.RegisterClientScriptIncludeInternal(item.Type, item.PathEmbedded);
                }
                else
                {
                    rm.RegisterClientScriptIncludeInternal(item.Type, item.PathEmbeddedDebug);
                }
            }
            else if (rm.RenderScripts == ResourceLocationType.File || rm.RenderScripts == ResourceLocationType.CacheFlyAndFile)
            {
                if (rm.ScriptMode == ScriptMode.Release || item.PathDebug.IsEmpty())
                {
                    rm.RegisterClientScriptIncludeInternal(item.PathEmbedded, rm.ResourcePathInternal.ConcatWith(item.Path));
                }
                else
                {
                    rm.RegisterClientScriptIncludeInternal(item.PathEmbedded, rm.ResourcePathInternal.ConcatWith(item.PathDebug));
                }
            }
        }
    }

    Quote Originally Posted by jchau View Post
    2. How do I add resources for gridpanel to the Resources property? If someone drops this control on a page, I want both my custom resources to be loaded plus the GridPanel resources.
    Please see the Example above.

Similar Threads

  1. Replies: 2
    Last Post: Jan 09, 2012, 7:18 AM
  2. [CLOSED] Hint in how to add Custom property to control
    By imaa in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Aug 17, 2011, 8:04 PM
  3. [CLOSED] [1.0] Extended Control Resources property called 3 times?
    By bsnezw in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 24, 2011, 7:16 PM
  4. Replies: 0
    Last Post: Apr 02, 2010, 7:06 PM
  5. [CLOSED] [1.0] Custom Control - How to embed resources?
    By rcaunt in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 19, 2010, 7:35 AM

Posting Permissions