RemoteValidation Versus Codebehind

  1. #1

    RemoteValidation Versus Codebehind

    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        Overloads Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            TextField1.Text = "123"
        End Sub
    
        Sub ValidateText(ByVal sender As Object, ByVal e As RemoteValidationEventArgs)
            Dim field As TextField = TryCast(sender, TextField)
            e.Success = (field.Text = "123")
            e.ErrorMessage = "Invalid field"
        End Sub
    
    </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></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager runat="server" />
        <ext:FormPanel ID="FormPanel1" runat="server" Title="Test Form" Border="true" Width="400"
            Height="100" MonitorValid="true" Layout="Form" Padding="5">
            <Items>
                <ext:TextField ID="TextField1" runat="server" MsgTarget="Qtip" AllowBlank="false"
                    FieldLabel="Text Field 1" Width="220" MaxLength="50" IsRemoteValidation="true">
                    <RemoteValidation OnValidation="ValidateText" />
                </ext:TextField>
            </Items>
            <Buttons>
                <ext:Button ID="SaveButton" runat="server" Text="Save">
                    <Listeners>
                        <Click Handler="if (!#{FormPanel1}.getForm().isValid()){Ext.Msg.show({icon: Ext.MessageBox.ERROR, msg: 'FormPanel is incorrect', buttons:Ext.Msg.OK});}" />
                    </Listeners>
                </ext:Button>
                <ext:Button ID="Button2" runat="server" Text="Cancel" />
            </Buttons>
            <Listeners>
                <ClientValidation Handler="el.getBottomToolbar().setStatus({text : valid ? 'Form is valid' : 'Form is invalid', iconCls: valid ? 'icon-accept' : 'icon-exclamation'});" />
            </Listeners>
        </ext:FormPanel>
        </form>
    </body>
    </html>
    Scnenario

    A form with a text field "TextField1" should only allow "123" as valid value, which is checked by RemoteValidation "ValidateText".

        <ext:TextField ID="TextField1" runat="server" MsgTarget="Qtip" AllowBlank="false"
            FieldLabel="Text Field 1" Width="220" MaxLength="50" IsRemoteValidation="true">
            <RemoteValidation OnValidation="ValidateText" />
        </ext:TextField>
    
        Sub ValidateText(ByVal sender As Object, ByVal e As RemoteValidationEventArgs)
            Dim field As TextField = TryCast(sender, TextField)
            e.Success = (field.Text = "123")
            e.ErrorMessage = "Invalid field"
        End Sub
    Problem
    Even when "TextField1" is assigned a valid value from codebehind, the "FormPanel is inocorrect".

        Overloads Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            TextField1.Text = "123"
        End Sub
    Please help!
    Last edited by NickBin; Dec 18, 2010 at 8:57 AM.

Similar Threads

  1. JSONP and Webservices versus Generic Handlers
    By plykkegaard in forum 1.x Help
    Replies: 3
    Last Post: Feb 21, 2012, 12:41 PM
  2. Replies: 6
    Last Post: Aug 01, 2011, 4:53 PM
  3. Page_Load() versus CreateChildControls()
    By LucJ in forum 1.x Help
    Replies: 2
    Last Post: Jul 16, 2010, 2:05 PM
  4. Replies: 7
    Last Post: May 12, 2010, 5:55 PM
  5. [CLOSED] Version 0.8 versus 1.0
    By turione in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 27, 2009, 7:39 PM

Tags for this Thread

Posting Permissions