[CLOSED] [1.0] New NameSpace property

  1. #1

    [CLOSED] [1.0] New NameSpace property

    I see a new Namespace property for all components, and was not quite sure what it's meant for. Is it the similar to what I blogged about here earlier:
    http://www.rahulsingla.com/blog/2010...ations-part-ii
    Last edited by Daniil; Oct 04, 2010 at 5:28 AM. Reason: [CLOSED]
  2. #2
    Hi Rahul,

    Yes, I think it is very similar. I did a quick read through your post, but I'll take a closer look later today and work up a sample demonstrating the .Namespace functionality.
    Geoffrey McGill
    Founder
  3. #3
    Thanks for the reply Geoff. I would look forward for the example.
  4. #4
    Hi Rahul,

    Here's a sample demonstrating the .Namespace property. Description below.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
      
    <script runat="server">
        protected void Button1_Click(object sender, DirectEventArgs e)
        {
            var msg = "Name : {0}<br />City : {1}<br />Country : {2}";
    
            msg = string.Format(msg, 
                this.txtFirstName.Text + " " + this.txtLastName.Text, 
                this.txtCity.Text, 
                this.txtCountry.Text);
            
            X.Msg.Notify("Information", msg).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>
        
        <script type="text/javascript">
            var doSomething = function () {
                var msg = "Name : {0}<br />City : {1}<br />Country : {2}",
                    x = CompanyX;
                
                msg = String.format(msg, 
                    x.txtFirstName.getValue() + " " + x.txtLastName.getValue(), 
                    x.address.txtCity.getValue(), 
                    x.address.country.getValue());
                
                Ext.Msg.notify("Information", msg);
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" Namespace="CompanyX" IDMode="Explicit" />
            
            <ext:Window
                ID="Window1" 
                runat="server" 
                Title="Example" 
                Height="215" 
                Width="350" 
                Padding="5"
                Layout="form">
                <Items>
                    <ext:TextField 
                        ID="txtFirstName" 
                        runat="server" 
                        FieldLabel="First Name" 
                        Text="Wayne" 
                        />
                    <ext:TextField 
                        ID="txtLastName" 
                        runat="server" 
                        FieldLabel="Last Name" 
                        Text="Gretzky" 
                        />
                    
                    <ext:FieldSet runat="server" Title="Address" Namespace=".address">
                        <Items>
                            <ext:TextField 
                                ID="txtCity" 
                                runat="server" 
                                FieldLabel="City" 
                                Text="L.A." 
                                />
                            <ext:TextField 
                                ID="txtCountry" 
                                ItemID="country" 
                                runat="server" 
                                FieldLabel="Country" 
                                Text="USA" 
                                />
                        </Items>
                    </ext:FieldSet>
                </Items>
                <Buttons>
                    <ext:Button runat="server" Text="Submit (Server)" OnDirectClick="Button1_Click" />
                    <ext:Button runat="server" Text="Submit (Client)" OnClientClick="doSomething();" />
                </Buttons>
            </ext:Window> 
        </form>
      </body>
    </html>
    Key points:

    1.) The .Namespace property is available on all Ext.NET Components and can be set on the <ext:ResourceManager>, in the Web.config and as an Application wide global variable.

    By default, if the .Namespace is set, the Ext.NET Components will add themselves by their .ClientID to the namespace object on the client

    Example

    // without .Namespace
    alert(txtFirstName.getValue());
    
    // with .Namespace
    alert(CompanyX.txtFirstName.getValue());
    2.) More than one .Namespace is permissible on the Page and group Components as required.

    3.) Namespaces are inherited by child components from the parent, although a child component create a new .Namespace which it (and all its children) will be added to.

    4.) Child components can create sub-namespaces. See the <ext:Fieldset> configuration above. All children of Fieldset will be added to the sub "address" object.

    Example

    alert(CompanyX.address.txtCity.getValue());

    5.) Setting the .ItemID will override the client-side .ClientID property and does not need to be unique on the page. See configuration for "txtCounty" above.

    Example

    alert(CompanyX.address.country.getValue());

    Hope this helps explain the property. Let us know if there's other functionality you would like that might be missing.
    Geoffrey McGill
    Founder
  5. #5
    Great... Overall, I see this in the same direction as in my blog post to manage client-side component references effectively. No doubt, this is a great way to do the same natively from the markup itself, and a good step forward for the toolkit.

    I had a couple of doubts, but would see this property in action before having concrete query to ask, if any. Thanks!!!
    Last edited by geoffrey.mcgill; Oct 01, 2010 at 8:55 PM.

Similar Threads

  1. [CLOSED] WebPages AND Namespace
    By CPA1158139 in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: May 26, 2012, 4:34 PM
  2. [CLOSED] Namespace property in DirectMethod
    By trieu.tran in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 06, 2012, 9:35 AM
  3. [CLOSED] Namespace Does not register
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 22
    Last Post: Nov 07, 2011, 10:10 AM
  4. [CLOSED] problem with old Namespace Example
    By pkellner in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 14, 2008, 5:37 PM
  5. [CLOSED] [MVC] namespace issue I think
    By pkellner in forum 1.x Legacy Premium Help
    Replies: 14
    Last Post: Sep 30, 2008, 11:47 AM

Tags for this Thread

Posting Permissions