[CLOSED] My message error is not with ActiveError in ServerSide

  1. #1

    [CLOSED] My message error is not with ActiveError in ServerSide

    Good night

    It is my code, When I load the first time the page I can to see the Msg of ActiveError

    Click image for larger version. 

Name:	ActiveError01.png 
Views:	15 
Size:	16.0 KB 
ID:	7412

    But, When I active the error with ActiveError in ServerSide, the Msg (with MsgTarget = "Under"), It's not

            <ext:ResourceManager ID="ResourceManager1" runat="server">
            </ext:ResourceManager>
            <ext:ComboBox ID="ComboBox1" runat="server" ActiveError="Sin seleccionar elemento" MsgTarget="Under">
                <Items>
                    <ext:ListItem Index="0" Text="Pechuga de pavo" Value="0" />
                    <ext:ListItem Index="1" Text="Pechuga de pollo" Value="1" />
                    <ext:ListItem Index="2" Text="Carne de res" Value="2" />
                    <ext:ListItem Index="3" Text="Tilapio" Value="3" />
                </Items>
                <DirectEvents>
                    <Select OnEvent="ComboBox1_Select" />
                </DirectEvents>
            </ext:ComboBox>
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
    
            protected void ComboBox1_Select(object sender, DirectEventArgs e)
            {
                if (Convert.ToInt32(ComboBox1.SelectedItem.Value) == 2)
                    ComboBox1.ActiveError = "Error al seleccionar carne de res";
            }
    Click image for larger version. 

Name:	ActiveError02.png 
Views:	12 
Size:	14.6 KB 
ID:	7413

    What is the problem?

    Thanks Ext.Net
    Last edited by Daniil; Dec 31, 2013 at 11:42 AM. Reason: [CLOSED]
  2. #2
    Hi @osef,

    To change an active error for a ComboBox on the fly, you should use the MarkInvalid method.
    if (Convert.ToInt32(ComboBox1.SelectedItem.Value) == 2)
    {
        ComboBox1.MarkInvalid("Error");
    }
    See also
    http://docs.sencha.com/extjs/4.2.1/#...setActiveError
    http://docs.sencha.com/extjs/4.2.1/#...od-markInvalid

    Personally, I don't like such a way to "validate" the fields, because it is not real validation. It just makes a field invalid visually. For example, if you call
    App.ComboBox1.isValid();
    it will return true and, moreover, resets the error.

    It might break the things in some scenarios. Especially, if a ComboBox is used inside a FormPanel.

    It is better to use real validation.
    Last edited by Daniil; Dec 27, 2013 at 12:07 PM.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @osef,

    To change an active error for a ComboBox on the fly, you should use the MarkInvalid method.
    if (Convert.ToInt32(ComboBox1.SelectedItem.Value) == 2)
    {
        ComboBox1.MarkInvalid("Error");
    }
    See also
    http://docs.sencha.com/extjs/4.2.1/#...setActiveError
    http://docs.sencha.com/extjs/4.2.1/#...od-markInvalid

    Personally, I don't like such a way to "validate" the fields, because it is not real validation. It just makes a field invalid visually. For example, if you call
    App.ComboBox1.isValid();
    it will return true and, moreover, resets the error.

    It might break the things in some scenarios. Especially, if a ComboBox is used inside a FormPanel.

    It is better to use real validation.
    So, Is it ActiveError a visual error? Because it is not working in a IsValid() of FormPanel, Is it true?
  4. #4
    Hello!

    Quote Originally Posted by osef View Post
    So, Is it ActiveError a visual error? Because it is not working in a IsValid() of FormPanel, Is it true?
    @Daniil meant that during DirectEvent you can change error message using:

    ComboBox1.MarkInvalid("Error");
    However, we suggest to use real validation like in this samples:

    https://examples2.ext.net/#/Form/Val...te_Validation/
    https://examples2.ext.net/#/Form/Val.../Custom_VType/
    https://examples2.ext.net/#/Form/FormPanel/Validation/
  5. #5
    Quote Originally Posted by Baidaly View Post
    Hello!



    @Daniil meant that during DirectEvent you can change error message using:

    ComboBox1.MarkInvalid("Error");
    However, we suggest to use real validation like in this samples:

    https://examples2.ext.net/#/Form/Val...te_Validation/
    https://examples2.ext.net/#/Form/Val.../Custom_VType/
    https://examples2.ext.net/#/Form/FormPanel/Validation/
    Thank you Baidaly, so, What is the function of the ActiveError and SetActiveError? I do not understand and can not find an example in a scenario that can explain it well.

    This documentation does not explain very well in that time I use this

    http://docs-origin.sencha.com/extjs/...setActiveError

    http://docs-origin.sencha.com/extjs/...fg-activeError
  6. #6
    Try the following:

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET Examples</title>
    
        <script runat="server">
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
    
            protected void ComboBox1_Select(object sender, DirectEventArgs e)
            {
                if (Convert.ToInt32(ComboBox1.SelectedItem.Value) == 2)
                    ComboBox1.SetActiveError("Error al seleccionar carne de res");
            }
        </script>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server">
        </ext:ResourceManager>
        <form runat="server">
            <ext:ComboBox ID="ComboBox1" runat="server" ActiveError="Sin seleccionar elemento" MsgTarget="Under">
                <Items>
                    <ext:ListItem Index="0" Text="Pechuga de pavo" Value="0" />
                    <ext:ListItem Index="1" Text="Pechuga de pollo" Value="1" />
                    <ext:ListItem Index="2" Text="Carne de res" Value="2" />
                    <ext:ListItem Index="3" Text="Tilapio" Value="3" />
                </Items>
                <DirectEvents>
                    <Select OnEvent="ComboBox1_Select" />
                </DirectEvents>
            </ext:ComboBox>
        </form>
    </body>
    </html>
    Does it meet your requirements?
  7. #7
    Quote Originally Posted by Baidaly View Post
    Try the following:

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET Examples</title>
    
        <script runat="server">
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
    
            protected void ComboBox1_Select(object sender, DirectEventArgs e)
            {
                if (Convert.ToInt32(ComboBox1.SelectedItem.Value) == 2)
                    ComboBox1.SetActiveError("Error al seleccionar carne de res");
            }
        </script>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server">
        </ext:ResourceManager>
        <form runat="server">
            <ext:ComboBox ID="ComboBox1" runat="server" ActiveError="Sin seleccionar elemento" MsgTarget="Under">
                <Items>
                    <ext:ListItem Index="0" Text="Pechuga de pavo" Value="0" />
                    <ext:ListItem Index="1" Text="Pechuga de pollo" Value="1" />
                    <ext:ListItem Index="2" Text="Carne de res" Value="2" />
                    <ext:ListItem Index="3" Text="Tilapio" Value="3" />
                </Items>
                <DirectEvents>
                    <Select OnEvent="ComboBox1_Select" />
                </DirectEvents>
            </ext:ComboBox>
        </form>
    </body>
    </html>
    Does it meet your requirements?
    These are some solutions:

        <form id="form1" runat="server">
    
            <ext:ResourceManager ID="ResourceManager1" runat="server">
            </ext:ResourceManager>
    
            <ext:ComboBox ID="ComboBox1" runat="server" ActiveError="Sin seleccionar elemento" MsgTarget="Under">
                <Items>
                    <ext:ListItem Index="0" Text="Pechuga de pavo" Value="0" />
                    <ext:ListItem Index="1" Text="Pechuga de pollo" Value="1" />
                    <ext:ListItem Index="2" Text="Carne de res" Value="2" />
                    <ext:ListItem Index="3" Text="Tilapio" Value="3" />
                </Items>
                <DirectEvents>
                    <Select OnEvent="ComboBox1_Select" />
                </DirectEvents>
            </ext:ComboBox>
    
        </form>
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
    
            protected void ComboBox1_Select(object sender, DirectEventArgs e)
            {
                if (Convert.ToInt32(ComboBox1.SelectedItem.Value) == 2)
                {
                    ComboBox1.SetActiveError("Error al seleccionar carne de res");
                    ComboBox1.DoComponentLayout();
                }
            }
    --------------------------------------------------------------------------------------------------------

        <form id="form1" runat="server">
    
            <ext:ResourceManager ID="ResourceManager1" runat="server">
            </ext:ResourceManager>
    
            <ext:FieldContainer
                ID="FieldContainer1"
                runat="server"
                Width="300"
                MsgTarget="Under"
                CombineErrors="true">
                <Items>
                    <ext:ComboBox ID="ComboBox2" runat="server">
                        <Items>
                            <ext:ListItem Index="0" Text="Pechuga de pavo" Value="0" />
                            <ext:ListItem Index="1" Text="Pechuga de pollo" Value="1" />
                            <ext:ListItem Index="2" Text="Carne de res" Value="2" />
                            <ext:ListItem Index="3" Text="Tilapio" Value="3" />
                        </Items>
                        <DirectEvents>
                            <Select OnEvent="ComboBox2_Select" />
                        </DirectEvents>
                    </ext:ComboBox>
                </Items>
            </ext:FieldContainer>
    
        </form>
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
    
            protected void ComboBox2_Select(object sender, DirectEventArgs e)
            {
                if (Convert.ToInt32(ComboBox2.SelectedItem.Value) == 2)
                    ComboBox2.SetActiveError("Error al seleccionar carne de res");
            }
    The problem is the method DoComponentLayout(), It is not in the before code.

    Thank you Baidaly and Daniil.

Similar Threads

  1. [CLOSED] Error message in IE8
    By RCM in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 16, 2013, 3:40 AM
  2. Replies: 1
    Last Post: Sep 13, 2012, 6:38 PM
  3. [CLOSED] New error message in V2
    By feanor91 in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 17, 2012, 1:57 PM
  4. [CLOSED] ActiveError a example
    By osef in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 16, 2012, 7:13 AM
  5. Custom Error Message
    By n_s_adhikari@rediffmail.com in forum 1.x Help
    Replies: 2
    Last Post: Aug 09, 2009, 5:36 PM

Tags for this Thread

Posting Permissions