[CLOSED] Validation Before Call to Handler with Multiple Forms

  1. #1

    [CLOSED] Validation Before Call to Handler with Multiple Forms

    Can you help me figure out how to validate pnlForm7 in the example below? I only want pnlForm7 to validate. This would work like Validation Groups. The validation needs to happen before the call to the handler, and prevent the handler call if the form is not valid.

    <%@ Page Language="C#" %>
     
    <!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>Testing</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" Theme="Gray">
        </ext:ResourceManager>
        <ext:Panel ID="pnlExport" runat="server" Title="Export Data" Border="false" Icon="ArrowOut" Padding="0" AutoScroll="true">
            <Items>
                <ext:FormPanel ID="pnlForm1" runat="server" Layout="FormLayout" Frame="true" ButtonAlign="Left" Border="false" Padding="5" Title="eScrip New Members" Margins="5" AutoHeight="true">
                    <Defaults>
                        <ext:Parameter Name="msgTarget" Value="side" Mode="Value">
                        </ext:Parameter>
                    </Defaults>
                    <Items>
                        <ext:ComboBox runat="server" ID="ddlMonth1" FieldLabel="Month" AllowBlank="false" TypeAhead="true" Editable="true" ForceSelection="true">
                            <Items>
                                <ext:ListItem Text="January" Value="1" />
                                <ext:ListItem Text="February" Value="2" />
                                <ext:ListItem Text="March" Value="3" />
                                <ext:ListItem Text="April" Value="4" />
                                <ext:ListItem Text="May" Value="5" />
                                <ext:ListItem Text="June" Value="6" />
                                <ext:ListItem Text="July" Value="7" />
                                <ext:ListItem Text="August" Value="8" />
                                <ext:ListItem Text="September" Value="9" />
                                <ext:ListItem Text="October" Value="10" />
                                <ext:ListItem Text="November" Value="11" />
                                <ext:ListItem Text="December" Value="12" />
                            </Items>
                        </ext:ComboBox>
                        <ext:ComboBox runat="server" ID="ddlYear1" AllowBlank="false" FieldLabel="Year" TypeAhead="true" Editable="true" ForceSelection="true">
                            <Items>
                                <ext:ListItem Text="2011" Value="2011" />
                                <ext:ListItem Text="2012" Value="2012" />
                            </Items>
                        </ext:ComboBox>
                    </Items>
                    <Buttons>
                        <ext:Button ID="btnGo1" runat="server" Text="GO">
                        </ext:Button>
                    </Buttons>
                </ext:FormPanel>
                <ext:FormPanel ID="pnlForm2" runat="server" Layout="FormLayout" Frame="true" ButtonAlign="Left" Padding="5" Border="false" Title="eScrip Rx Usage" Margins="5" AutoHeight="true">
                    <Defaults>
                        <ext:Parameter Name="msgTarget" Value="side" Mode="Value">
                        </ext:Parameter>
                    </Defaults>
                    <Items>
                        <ext:ComboBox runat="server" ID="ddlMonth2" FieldLabel="Month" AllowBlank="false" TypeAhead="true" Editable="true" ForceSelection="true">
                            <Items>
                                <ext:ListItem Text="January" Value="1" />
                                <ext:ListItem Text="February" Value="2" />
                                <ext:ListItem Text="March" Value="3" />
                                <ext:ListItem Text="April" Value="4" />
                                <ext:ListItem Text="May" Value="5" />
                                <ext:ListItem Text="June" Value="6" />
                                <ext:ListItem Text="July" Value="7" />
                                <ext:ListItem Text="August" Value="8" />
                                <ext:ListItem Text="September" Value="9" />
                                <ext:ListItem Text="October" Value="10" />
                                <ext:ListItem Text="November" Value="11" />
                                <ext:ListItem Text="December" Value="12" />
                            </Items>
                        </ext:ComboBox>
                        <ext:ComboBox runat="server" ID="ddlYear2" AllowBlank="false" FieldLabel="Year" TypeAhead="true" Editable="true" ForceSelection="true">
                            <Items>
                                <ext:ListItem Text="2011" Value="2011" />
                                <ext:ListItem Text="2012" Value="2012" />
                            </Items>
                        </ext:ComboBox>
                    </Items>
                    <Buttons>
                        <ext:Button ID="btnGo2" runat="server" Text="GO">
                        </ext:Button>
                    </Buttons>
                </ext:FormPanel>
                <ext:FormPanel ID="pnlForm3" runat="server" Layout="FormLayout" Frame="true" ButtonAlign="Left" Padding="5" Border="false" Title="Eligibility" Margins="5" AutoHeight="true">
                    <Defaults>
                        <ext:Parameter Name="msgTarget" Value="side" Mode="Value">
                        </ext:Parameter>
                    </Defaults>
                    <Items>
                        <ext:ComboBox ID="ddlGroup_Eligibility" runat="server" FieldLabel="Group" AllowBlank="false">
                            <Items>
                                <ext:ListItem Text="Group1" Value="1" />
                                <ext:ListItem Text="Group2" Value="2" />
                            </Items>
                        </ext:ComboBox>
                        <ext:ComboBox runat="server" ID="ddlMonth_Eligibility" FieldLabel="Month" AllowBlank="false" TypeAhead="true" Editable="true" ForceSelection="true">
                            <Items>
                                <ext:ListItem Text="January" Value="1" />
                                <ext:ListItem Text="February" Value="2" />
                                <ext:ListItem Text="March" Value="3" />
                                <ext:ListItem Text="April" Value="4" />
                                <ext:ListItem Text="May" Value="5" />
                                <ext:ListItem Text="June" Value="6" />
                                <ext:ListItem Text="July" Value="7" />
                                <ext:ListItem Text="August" Value="8" />
                                <ext:ListItem Text="September" Value="9" />
                                <ext:ListItem Text="October" Value="10" />
                                <ext:ListItem Text="November" Value="11" />
                                <ext:ListItem Text="December" Value="12" />
                            </Items>
                        </ext:ComboBox>
                        <ext:ComboBox runat="server" ID="ddlYear_Eligibility" AllowBlank="false" FieldLabel="Year" TypeAhead="true" Editable="true" ForceSelection="true">
                            <Items>
                                <ext:ListItem Text="2011" Value="2011" />
                                <ext:ListItem Text="2012" Value="2012" />
                            </Items>
                        </ext:ComboBox>
                    </Items>
                    <Buttons>
                        <ext:Button ID="btnGo3" runat="server" Text="GO">
                        </ext:Button>
                    </Buttons>
                </ext:FormPanel>
                <ext:FormPanel ID="pnlForm4" runat="server" Layout="FormLayout" Frame="true" ButtonAlign="Left" Padding="5" Border="false" Title="Access Full File (45001059)" Margins="5" AutoHeight="true">
                    <Defaults>
                        <ext:Parameter Name="msgTarget" Value="side" Mode="Value">
                        </ext:Parameter>
                    </Defaults>
                    <Buttons>
                        <ext:Button ID="btnGo4" runat="server" Text="GO">
                        </ext:Button>
                    </Buttons>
                </ext:FormPanel>
                <ext:FormPanel ID="pnlForm5" runat="server" Layout="FormLayout" Frame="true" ButtonAlign="Left" Padding="5" Border="false" Title="Access Daily File (45001059)" Margins="5" AutoHeight="true">
                    <Defaults>
                        <ext:Parameter Name="msgTarget" Value="side" Mode="Value">
                        </ext:Parameter>
                    </Defaults>
                    <Items>
                        <ext:DateField ID="dfDay_AccessDaily" runat="server" FieldLabel="Day" AllowBlank="false">
                        </ext:DateField>
                    </Items>
                    <Buttons>
                        <ext:Button ID="btnGo5" runat="server" Text="GO">
                        </ext:Button>
                    </Buttons>
                </ext:FormPanel>
                <ext:FormPanel ID="pnlForm6" runat="server" Layout="FormLayout" Frame="true" ButtonAlign="Left" Padding="5" Border="false" Title="Careington Full File" Margins="5" AutoHeight="true">
                    <Defaults>
                        <ext:Parameter Name="msgTarget" Value="side" Mode="Value">
                        </ext:Parameter>
                    </Defaults>
                    <Buttons>
                        <ext:Button ID="btnGo6" runat="server" Text="GO">
                        </ext:Button>
                    </Buttons>
                </ext:FormPanel>
                <ext:FormPanel ID="pnlForm7" runat="server" Layout="FormLayout" Frame="true" ButtonAlign="Left" Padding="5" Border="false" Title="Careington Daily Update File" Margins="5" AutoHeight="true">
                    <Defaults>
                        <ext:Parameter Name="msgTarget" Value="side" Mode="Value">
                        </ext:Parameter>
                    </Defaults>
                    <Items>
                        <ext:DateField ID="dfDay_CareingtonDaily" runat="server" FieldLabel="Day" AllowBlank="false">
                        </ext:DateField>
                    </Items>
                    <Buttons>
                        <ext:Button ID="btnGo7" runat="server" Text="GO">
                            <DirectEvents>
                                <Click Url="/Handlers/GetDataExportFile.ashx?type=CareingtonDaily" Json="true" Method="POST" IsUpload="true">
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                    </Buttons>
                </ext:FormPanel>
                <ext:FormPanel ID="pnlForm8" runat="server" Layout="FormLayout" Frame="true" ButtonAlign="Left" Padding="5" Border="false" Title="HealthAdvocate Monthly Update File" Margins="5" AutoHeight="true">
                    <Defaults>
                        <ext:Parameter Name="msgTarget" Value="side" Mode="Value">
                        </ext:Parameter>
                    </Defaults>
                    <Items>
                        <ext:ComboBox runat="server" ID="ddlMonth_HealthAdvocateMonthly" FieldLabel="Month" AllowBlank="false" TypeAhead="true" Editable="true" ForceSelection="true">
                            <Items>
                                <ext:ListItem Text="January" Value="1" />
                                <ext:ListItem Text="February" Value="2" />
                                <ext:ListItem Text="March" Value="3" />
                                <ext:ListItem Text="April" Value="4" />
                                <ext:ListItem Text="May" Value="5" />
                                <ext:ListItem Text="June" Value="6" />
                                <ext:ListItem Text="July" Value="7" />
                                <ext:ListItem Text="August" Value="8" />
                                <ext:ListItem Text="September" Value="9" />
                                <ext:ListItem Text="October" Value="10" />
                                <ext:ListItem Text="November" Value="11" />
                                <ext:ListItem Text="December" Value="12" />
                            </Items>
                        </ext:ComboBox>
                        <ext:ComboBox runat="server" ID="ddlYear_HealthAdvocateMonthly" AllowBlank="false" FieldLabel="Year" TypeAhead="true" Editable="true" ForceSelection="true">
                            <Items>
                                <ext:ListItem Text="2011" Value="2011" />
                                <ext:ListItem Text="2012" Value="2012" />
                            </Items>
                        </ext:ComboBox>
                    </Items>
                    <Buttons>
                        <ext:Button ID="btnGo8" runat="server" Text="GO">
                        </ext:Button>
                    </Buttons>
                </ext:FormPanel>
                <ext:FormPanel ID="pnlForm9" runat="server" Layout="FormLayout" Frame="true" ButtonAlign="Left" Padding="5" Border="false" Title="Type 12 File" Margins="5" AutoHeight="true">
                    <Defaults>
                        <ext:Parameter Name="msgTarget" Value="side" Mode="Value">
                        </ext:Parameter>
                    </Defaults>
                    <Items>
                        <ext:ComboBox ID="cboCompany" runat="server" FieldLabel="Company" AllowBlank="false">
                            <Items>
                                <ext:ListItem Text="Company1" Value="1" />
                                <ext:ListItem Text="Company2" Value="2" />
                            </Items>
                        </ext:ComboBox>
                    </Items>
                    <Buttons>
                        <ext:Button ID="btnGo9" runat="server" Text="GO">
                        </ext:Button>
                    </Buttons>
                </ext:FormPanel>
            </Items>
        </ext:Panel>
        </form>
    </body>
    </html>
    And here's the code for the handler, called GetDataExportFile.ashx:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Ext.Net;
    using LogicSpeak.Extensions;
    using ApexAffinity.Capture.BLL;
    using ApexAffinity.Capture.Components;
    using ApexAffinity.Capture.Library.Data;
    using System.Collections.Specialized;
    using System.Xml;
    using Newtonsoft.Json;
     
    namespace ApexAffinity.Capture.Website.Handlers
    {
        /// <summary>
        /// Summary description for GetDataExportFile
        /// </summary>
        public class GetDataExportFile : IHttpHandler
        {
            public void ProcessRequest(HttpContext context)
            {
                string username = context.User.Identity.Name;
                string type = context.Request.QueryString["type"].ToString();
     
                switch (type.ToUpper())
                {
                    case "EXCEPTIONS":
                        break;
                    case "ESCRIPNEWMEMBERS":
                        break;
                    case "ESCRIPUSAGE":
                        break;
                    case "ELIGIBILITY":
                        break;
                    case "ACCESSFULL":
                        break;
                    case "ACCESSDAILY":
                        break;
                    case "CAREINGTONDAILY":
                        break;
                    case "CAREINGTONFULL":
                        break;
                    case "HEALTHADVOCATEMONTHLY":
                        break;
                    case "TYPE12":
                        break;
                }
            }
     
            public string GetExtraParam(HttpContext context, string paramName)
            {
                string parameter = "";
                ParameterCollection extraParams = new ParameterCollection();
                
                foreach (string item in context.Request.Form.AllKeys)
                {
                    if (item.EndsWith("submitDirectEventConfig"))
                    {
                        string jsondata = context.Request.Form[item];
                        XmlNode submitConfig = JsonConvert.DeserializeXmlNode(jsondata);
                        XmlNode extraParamsNode = submitConfig.SelectSingleNode("config/extraParams");
                        extraParams = ResourceManager.XmlToParams(extraParamsNode);
                        parameter = extraParams[paramName];
                    }
                }
                
                return parameter;
            }
     
            public string GetFormValue(NameValueCollection form, string control)
            {
                string toReturn = String.Empty;
     
                foreach (string key in form.AllKeys)
                {
                    if (key.EndsWith(control))
                    {
                        toReturn = form[key];
                    }
                }
     
                return toReturn;
            }
     
            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
    }
    Last edited by Daniil; Jan 12, 2012 at 3:48 PM. Reason: [CLOSED]
  2. #2
    Hi,

    To validate a FormPanel, please call its isValid method.

    To prevent a DirectEvent, please return false from its Before handler.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Submit(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("Submit", "Submitted!").Show();
        }
    </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>Ext.NET Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:FormPanel ID="FormPanel1" runat="server">
                <Items>
                    <ext:TextField runat="server" FieldLabel="TextField" AllowBlank="false" />
                </Items>
            </ext:FormPanel>
            <ext:Button runat="server" Text="Submit">
                <DirectEvents>
                    <Click OnEvent="Submit" Before="return FormPanel1.isValid();" />
                </DirectEvents>
            </ext:Button>
        </form>
    </body>
    </html>
  3. #3
    Ok, that worked once I used the curly braces:

    <ext:Button ID="btnGo7" runat="server" Text="GO">
        <DirectEvents>
            <Click Before="return #{pnlForm7}.isValid();" Url="/Handlers/GetDataExportFile.ashx?type=CareingtonDaily" Json="true" Method="POST" IsUpload="true">
            </Click>
        </DirectEvents>
    </ext:Button>
    Thanks!

Similar Threads

  1. Replies: 4
    Last Post: Jun 29, 2012, 1:36 PM
  2. Adding multiple partial views in single call
    By Tallmaris in forum 1.x Help
    Replies: 0
    Last Post: Sep 14, 2011, 1:26 PM
  3. Helpme, Validation of Forms.
    By julioc_m18 in forum 1.x Help
    Replies: 0
    Last Post: Feb 07, 2011, 11:29 PM
  4. how to call the usercontrol in render handler
    By krishna in forum 1.x Help
    Replies: 1
    Last Post: Dec 27, 2010, 9:43 AM
  5. [CLOSED] Window + Tab + multiple Forms = Layout Help!
    By jchau in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 29, 2009, 5:32 PM

Posting Permissions