Jun 06, 2012, 7:12 PM
[CLOSED] fire the DirectEvent ONLY when form is valid
Hello,
I am trying to save my form's vales only when the form is validated correctly. But the code I get from this link (https://examples1.ext.net/#/Form/FormPanel/Validation/) always fire the DirectEvent call regardless of the form's status.
Is there anyway to make the DirectEvent fires only when the form is valid?
Below is my code:
I am trying to save my form's vales only when the form is validated correctly. But the code I get from this link (https://examples1.ext.net/#/Form/FormPanel/Validation/) always fire the DirectEvent call regardless of the form's status.
Is there anyway to make the DirectEvent fires only when the form is valid?
Below is my code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="Web.Pages.test" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!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>
<style type="text/css">
.icon-exclamation
{
padding-left: 25px !important;
background: url(/icons/exclamation-png/ext.axd) no-repeat 3px 3px !important;
}
.icon-accept
{
padding-left: 25px !important;
background: url(/icons/accept-png/ext.axd) no-repeat 3px 3px !important;
}
</style>
<script runat="server">
protected void BtnSaveClick(object sender, DirectEventArgs e)
{
X.Msg.Notify("The Server Time is: ", DateTime.Now.ToLongTimeString()).Show();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager runat="server" />
<ext:FormPanel ID="FormPanel1" runat="server" Title="FormPanel Validation (all fields required)"
MonitorPoll="500" MonitorValid="true" Padding="5" Width="600" Height="250" ButtonAlign="Right"
Layout="Column">
<items>
<ext:Panel runat="server" Border="false" Header="false" ColumnWidth=".5" Layout="Form" LabelAlign="Top">
<Defaults>
<ext:Parameter Name="AllowBlank" Value="false" Mode="Raw" />
<ext:Parameter Name="MsgTarget" Value="side" />
</Defaults>
<Items>
<ext:TextField ID="TextField1" runat="server" FieldLabel="First Name" AnchorHorizontal="92%" />
<ext:TextField runat="server" FieldLabel="Company" AnchorHorizontal="92%" />
</Items>
</ext:Panel>
<ext:Panel runat="server" Border="false" Layout="Form" ColumnWidth=".5" LabelAlign="Top">
<Defaults>
<ext:Parameter Name="AllowBlank" Value="false" Mode="Raw" />
<ext:Parameter Name="MsgTarget" Value="side" />
</Defaults>
<Items>
<ext:TextField runat="server" FieldLabel="Last Name" AnchorHorizontal="92%" />
<ext:TextField runat="server" FieldLabel="Email" Vtype="email" AnchorHorizontal="92%" />
</Items>
</ext:Panel>
</items>
<buttons>
<ext:Button runat="server" Text="Save">
<DirectEvents>
<Click OnEvent="BtnSaveClick">
<EventMask ShowMask="true" Msg="Saving Run Details..." />
</Click>
</DirectEvents>
<Listeners>
<Click Handler="if (#{FormPanel1}.getForm().isValid()) {Ext.Msg.alert('Submit', 'Saved!');}else{Ext.Msg.show({icon: Ext.MessageBox.ERROR, msg: 'FormPanel is incorrect', buttons:Ext.Msg.OK});}" />
</Listeners>
</ext:Button>
<ext:Button runat="server" Text="Cancel" />
</buttons>
<bottombar>
<ext:StatusBar runat="server" Height="25" />
</bottombar>
<listeners>
<ClientValidation Handler="this.getBottomToolbar().setStatus({text : valid ? 'Form is valid' : 'Form is invalid', iconCls: valid ? 'icon-accept' : 'icon-exclamation'});" />
</listeners>
</ext:FormPanel>
</form>
</body>
</html>
Last edited by Daniil; Jun 07, 2012 at 1:03 PM.
Reason: [CLOSED]