[CLOSED] What is the Resource Manager and how do I use it?

  1. #1

    [CLOSED] What is the Resource Manager and how do I use it?

    Please explain or point to an explanation. I am not looking for the api / members / properties. I don't know what it is or how to use it.
  2. #2
    Hi,

    The main function of the <ext:ResourceManager> is to control and load the JavaScript files required by the Ext.NET Controls. There are other features, such as changing the .Theme, controlling script compression, page level JavaScript event handlers, etc...

    ... or how to use it
    Just add a single instance of the <ext:ResourceManager> to your Page.

    Here's a basic page demonstrating placement of the <ext:ResourceManager> and use of a basic DirectEvent Ajax call.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    
    <script runat="server">
        protected void Button1_Click(object sender, DirectEventArgs e)
        {
            X.Msg.Notify("Message", this.TextField1.Text).Show();
        }
    </script>
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:Window 
                runat="server" 
                Title="Example"
                Padding="5"
                Height="215"
                Width="350">
                <Items>
                    <ext:TextField ID="TextField1" runat="server" FieldLabel="Item 1" />
                </Items>
                <Buttons>
                    <ext:Button runat="server" Text="Submit" OnDirectClick="Button1_Click" />
                </Buttons>
            </ext:Window>
        </form>
    </body>
    </html>
    Hope this helps.
    Geoffrey McGill
    Founder
  3. #3
    Ok, I understand this much. Question: if I have my own custom resources such as css and javascript files, is the ResourceManager the way to manage them? I saw on the API that it has, e.g., a LoadClientScriptInclude method. However I wasn't sure how to provide the correct parameters to indicate my script location for loading.
  4. #4
    The most basic and simplest method of adding your js/css files to the page is just adding them in the HTML source.

    The following sample demonstrates adding a single .css and .js file into the <head> section of the page.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET Example</title>
    
    
        <link rel="stylesheet" type="text/css" href="example.css" />
        <script type="text/javascript" src="example.js"></script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
        </form>
    </body>
    </html>
    In the above sample:

    1. The Ext.NET .js files will be loaded after example.js.
    2. The Ext.NET .css files will be loaded before example.css.

    If you require loading of the Ext.NET .js files before example.js you can add the following <ext:ResourcePlaceHolder> at any location. The Ext.NET ResourceManager will write directly to the location of the <ext:ResourcePlaceHolder>.

    Example

    <%@ Page Language="C#" %>
    
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET Example</title>
    
    
        <ext:ResourcePlaceHolder runat="server" />
    
    
        <link rel="stylesheet" type="text/css" href="CSS PATH HERE" />
        <script type="text/javascript" src="PATH HERE"></script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
        </form>
    </body>
    </html>
    The .Mode property of the <ext:ResourcePlaceHolder> allows for further customization.

    The following sample demonstrates use of the .Mode property to split rendering of the required .css and .js files by the ResourcePlaceHolder into two locations.

    Example

    <%@ Page Language="C#" %>
    
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET Example</title>
        <ext:ResourcePlaceHolder runat="server" Mode="Style" />
        <link rel="stylesheet" type="text/css" href="CSS PATH HERE" />
    
    
        <ext:ResourcePlaceHolder runat="server" Mode="Script" />
        <script type="text/javascript" src="PATH HERE"></script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
        </form>
    </body>
    </html>
    
    Hope this helps.
    Geoffrey McGill
    Founder
  5. #5
    Many thanks, this cleared up several questions I had.

Similar Threads

  1. [CLOSED] resource manager and limiting extjs file size
    By craig2005 in forum 1.x Legacy Premium Help
    Replies: 9
    Last Post: Oct 03, 2013, 9:41 AM
  2. Replies: 1
    Last Post: Mar 07, 2012, 8:57 PM
  3. Script Manager and Resource Manager Conflict
    By EugeneNiemand in forum 1.x Help
    Replies: 6
    Last Post: Jun 20, 2011, 7:34 AM
  4. Replies: 5
    Last Post: Oct 26, 2010, 2:20 PM
  5. Replies: 4
    Last Post: Sep 22, 2010, 7:43 AM

Posting Permissions