[OPEN] [#257] Namespace and ID issue in v2.2

Page 1 of 5 123 ... LastLast
  1. #1

    [OPEN] [#257] Namespace and ID issue in v2.2

    Hi,
    I am testing version 2.2. I have a issue with namespacing which worked well in v2.2.

    Here's my code to test:

    For Page:
    <%@ Page Language="C#" %>
     
    <%@ Import Namespace="System.Globalization" %>
    <%@ Import Namespace="System.Collections.Generic" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     <%@ Register Src="~/test/uc.ascx" TagName="test" TagPrefix="uc1" %>
    
    
    
    
    <!DOCTYPE html>
    
    
    <html>
    <head id="Head1" runat="server">
    
    
         
        
     
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server"/>
             
            
            <uc1:test ID="test1" runat="server" />
        </form>
      </body>
    </html>
    For Control:
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="uc.ascx.cs" Inherits="test.uc" %>
    <ext:Panel ID="panel1" ItemID="panel1" runat="server" Width="500" Height="500" Namespace="Controls" Title="UC Panel">
                <Content>Hello</Content>
            </ext:Panel>

    In version 2.1, I could access panel1 as Controls.panel1
    In version 2.2, it has changed to Controls.test1_panel1

    The only way to make it work is to have IDMode="static" in web.config. But in that case I am getting endless errors of ID already used. In version 2.1, I had to just specify ItemID and it would become unique name in a namespace, nothing else required. Just to upgrae to 2.2 I will have to make lots of changes everywhere.

    Please advise.
    Last edited by Daniil; May 30, 2013 at 4:22 AM. Reason: [OPEN] [#257]
  2. #2
    You specified ID and ItemID
    ID has a priority over ItemID (in v2.1 it was a bug, ItemID had a priority)

    Therefore please remove ID or use IDMode=Static for panel1 (not for all widgets via web.config)
  3. #3
    Hi Vlad,
    Having specified just itemid, I lose the access to the control in code behind. I need to specify the ID for that. With ID and ItemID specified, It would work just fine.
  4. #4
    In this case, specify IDMode=Static for panel1
  5. #5
    Hi Vlad,
    I am not talking about this case in specific.

    For eg: I have button with ID="btnSubmit" in one control and button with ID="btnSubmit" in another control. If I have IDMode=Static for both of them, it will again throw error. So when I specify IDMode="Static" it will need to be unique across app which is very difficult. Why can't it just remain same as before?

    Or is it possible to access the control with just itemid specified in code behind?
  6. #6
    For eg: I have button with ID="btnSubmit" in one control and button with ID="btnSubmit" in another control. If I have IDMode=Static for both of them, it will again throw error.
    Then use different namespaces for those controls. Why don't you worry about the same error if you specify the same ItemID and Namespace for two controls?

    Why can't it just remain same as before?
    Because it was a bug. If ID is specified then it should be used for global sharing of instance. ItemID should be used for local searching (within a container), it is not designed for global sharing
    ItemID is used as global id in one case only: if no ID and there is own Namespace for the widget, in this case ItemID will be shared in that namespace

    Or is it possible to access the control with just itemid specified in code behind?
    Only if search controls manually via Controls collection
  7. #7
    Hi Vlad,
    Even if I have different namespaces, it will still throw error. Consider following in 2 different controls :

    Control 1
    <ext:button ID="btnSubmit" ItemID="btnSubmit" Namespace = "Controls" IDMode="Static"></ext:button>

    Control 2
    <ext:button ID="btnSubmit" ItemID="btnSubmit" Namespace = "Search" IDMode="Static"></ext:button>

    Won't it throw error for not being unique across website?

    As per your solution, I will need to specify ID, if I want access on code behind, make it static, so that it shows correct ID on client side and ensure its unique across the website.
    Last edited by Daniil; Apr 08, 2013 at 6:09 AM. Reason: Please use [CODE] tags
  8. #8
    Even if I have different namespaces, it will still throw error.
    Yes, i forgot that on server side will be such error because namespace is client side only

    As per your solution, I will need to specify ID, if I want access on code behind, make it static, so that it shows correct ID on client side and ensure its unique across the website.
    Is ItemID unique in your application? If ItemID is not unique than second widget shared variable will replace first widget variable (when you used v2.1)
    If yes then use ItemID value as ID with IDMode=Static, if no then ID uniqueness is your responsibility (not framework). Framework cannot set ID, it use already set ID and generate client id according to IDMode

    May be you need to consider to use one of the following IDMode
    /// <summary>
    /// The ClientID value is generated by concatenating the ID value of the parent naming container with the ID value of the control. Each segment is separated by an underscore character (_).
    /// </summary>
    Predictable,


    /// <summary>
    /// The ClientID value is generated by concatenating the ID value of the parent Ext.NET component of the parent naming container with the ID value of the control. Each segment is separated by an underscore character (_).
    /// </summary>
    Parent
  9. #9
    Hi Vlad,
    ItemID is not Unique. But combination of ItemID and Namespace are unique. So in a namespace, there will always be one control with a specific id.

    Just to ensure what I was doing in 2.1 works, I will need to ensure uniqueness of ID's across lots of forms. There are more than 150 forms on which our application is based. Innumerable fields. Its a complex app which uses client side ids as well as server side id on code behind.

    May be you are right with your solution, but having being working on 2.1 which was a stable release, I expect transition to be easier rather that doing so many changes.
  10. #10
    Hi Vlad,
    I added IDMode="Ignore" and its working on my test samples. I will update you tomm with my actual product. May be in 2.1, IDMode was by default Ignore for the controls and thats why it worked?
Page 1 of 5 123 ... LastLast

Similar Threads

  1. Help with TreeNode namespace
    By zXSwordXz in forum 2.x Help
    Replies: 4
    Last Post: Oct 27, 2012, 3:36 AM
  2. [CLOSED] 'Model' is a namespace but is used like a 'type'
    By Fahd in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 10, 2012, 3:12 PM
  3. Ext.Net.Calender Namespace
    By Rupesh in forum 1.x Help
    Replies: 5
    Last Post: Feb 24, 2012, 12:56 PM
  4. [CLOSED] Namespace Does not register
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 22
    Last Post: Nov 07, 2011, 10:10 AM
  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

Posting Permissions