[CLOSED] Create web server control (composite control)

  1. #1

    [CLOSED] Create web server control (composite control)

    I created a web server control (composite control) that contains an Ext: TextField.

    The following structure was encapsulated in Web server control:
    <ext:CompositeField ID="CompositeField1" runat="server"
                        FieldLabel="Usuário" LabelAlign="Right" 
                        IndicatorIconCls="form-icon-mandatory" 
                        MsgTarget="Side" Width="227" >
        <Items>
            <ext:TextField ID="TextField1" runat="server"
                 AllowBlank="false" 
                 Width="200" >
            </ext:TextField>
    </ext:CompositeField>
    I have a page that implements the Web server control and an Ex: Button that runs the validation of information.

        <form id="form1" runat="server">
             <ext:ResourceManager ID="ResourceManager1" runat="server"/>
             <ext:Viewport runat="server" ID="ViewPort1" >
                <Items>
                    <ext:FormPanel ID="frmDetails" runat="server" Border="false" BodyStyle="background-color:transparent;"
                                Width="1120" Height="670" >
                        <Items>
                            <ext:Panel ID="Panel1" runat="server" Border="false" EnableViewState="true">
                                <Items>
                                    <ext:Button ID="btnApply" runat="server" Text="Aplicar" IconCls="toolbar-icon-apply-n">
                                        <DirectEvents>
                                            <Click OnEvent="ToolBarClick" Before="return #{frmDetails}.getForm().isValid();">
                                            </Click>
                                        </DirectEvents>
                                    </ext:Button>
                                </Items>
                                <Content>
                                    <Sispro:SUtText ID="SUtText1" runat="server" FieldLabel="teste" Width="100" >
                                    </Sispro:SUtText>
                                </Content>
                            </ext:Panel>
                        </Items>
                    </ext:FormPanel>
                </Items>
            </ext:Viewport>
        </form>
    When I type an invalid content in the text, the field is marked as invalid, but clicking the button "btnApply", the code "getForm().isValid()" returns "true", allowing the execution of the event "ToolBarClick".

    If I place the structure of the "ext:CompositeField" right on the page rather than the Web server control "SUtText1", by clicking the "btnApply", the command "getForm().isValid()" returns "false", not allowing the execution of the event "ToolBarClick". This is the correct procedure.

    I need to implement some code in the web server control for the correct functioning of the "isValid()"?

    Is there any example that makes this type of implementation?
    Last edited by Daniil; May 17, 2011 at 2:07 PM. Reason: [CLOSED]
  2. #2
    Hi,

    You should use <Items> instead of <Content>.
    <Items>
        <Sispro:SUtText ...>
    </Items>
  3. #3
    I did this but the following error occurs on the page:

    Parser Error 
    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 
    
    Parser Error Message: Ext.Net.ItemsCollection`1[[Ext.Net.Component, Ext.Net, Version=1.0.4132.33779, Culture=neutral, PublicKeyToken=2e12ce3d0176cd87]] must have items of type 'Ext.Net.Component'. 'Sispro:SUtText' is of type 'Sispro.Ut.Geral.PL.SUtTxtI500.SUtText'.
    
    Source Error: 
    
    Line 49:                             </Content>
    Line 50:                             <Items>
    Line 51:                                 <Sispro:SUtText ID="SUtText1" runat="server" Validation-IsRequired="true" FieldLabel="teste" Width="100" >
    Line 52:                                 </Sispro:SUtText>
    Line 53:                                             <ext:CompositeField ID="CompositeField1" runat="server"
     
    
    Source File: /Default.aspx    Line: 51

    --------------------------------------------------------------------------------
    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
    Last edited by geoffrey.mcgill; May 13, 2011 at 6:22 PM. Reason: please use [CODE] tags
  4. #4
    Well, how do you create a web server control? I guess you meant a web user control.
  5. #5
    sorry, the correct name is Composite Server control. See part of the definition:

    #region Class Attributes
    
    [
    
    AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal),
    
    AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal),
    
    ToolboxData("<{0}:SUtText runat=\"server\"></{0}:SUtText>"),
    
    ToolboxBitmap(typeof(SUtText), "Contents.Text.Images.suttext.bmp"),
    
    ParseChildren(true),
    
    PersistChildren(false),
    
    DefaultEvent("ValidateField"),
    
    DefaultProperty("Text"),
    
    Designer(typeof(SUtTextDesigner))
    
    ]
    
    #endregion Class Attributes
    
    public class SUtText : CompositeControl
    
    {
    
    }
  6. #6
    Hmm, what is the CompositeControl? System.Web.UI.WebControls.CompositeControl?

    You should be able to directly extend CompositeField control.

    I should clarify - <Content> of FormPanel doesn't make sense and don't allow to use FormPanel's features like .isValid().
  7. #7
    Yes, it's a System.Web.UI.WebControls.CompositeControl. There is how to implement this validation in a CompositeControl that reuse the Ext.Net?
  8. #8
    Unfortunately, there is no way.

    Only Ext.Net.Field's inheritors will allow to use FormPanel's features like validation.

Similar Threads

  1. [CLOSED] Need for a composite control extending Ext.NET
    By Aparna_B in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 10, 2011, 5:38 PM
  2. [CLOSED] [1.0] Help with composite control
    By russ in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 16, 2011, 10:16 AM
  3. Replies: 2
    Last Post: Apr 20, 2010, 1:50 PM
  4. COMPOSITE SERVER SIDE CONTROL(gridPanel)
    By marcmvc in forum 1.x Help
    Replies: 1
    Last Post: Apr 15, 2010, 4:45 PM
  5. Replies: 6
    Last Post: Sep 01, 2009, 1:06 PM

Posting Permissions