PDA

View Full Version : [CLOSED] Dynamics validation



kakashi
Oct 26, 2013, 2:38 PM
Hi I'm working in an application and I have different type of client in different country so For each country there are different form validation for the same form. I want to know if it's possible to dynamics validation per country with EXT.net.

Daniil
Oct 28, 2013, 4:48 AM
Hi @kakashi,

Welcome to the Ext.NET forums!

I am afraid I don't quite understand the following.

dynamics validation per country

Could you elaborate in details, please?

Also please clarify do you use a FormPanel with Ext.NET fields?

If so, you can configure validation as you need according to the current culture.

Also you might need to set up the Culture or a ResourceManager's Locale.

kakashi
Oct 28, 2013, 5:55 PM
Hi @kakashi,

Welcome to the Ext.NET forums!

I am afraid I don't quite understand the following.


Could you elaborate in details, please?

Also please clarify do you use a FormPanel with Ext.NET fields?

If so, you can configure validation as you need according to the current culture.

Also you might need to set up the Culture or a ResourceManager's Locale.

We use FormPanel, I joined an example of what I want. 7137
I want to know if Ext can allow me to do something like that. Dynamics validation on one formpanel controls.

Baidaly
Oct 28, 2013, 6:58 PM
Hello!

Welcome to our forum! You can do it in Page_Load method by setting AllowBlank property.

Take a look at this sample:


<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
HttpRequest Request = HttpContext.Current.Request;
if (Request.UserLanguages == null)
return;

string Lang = Request.UserLanguages[0];
if (Lang == "ru-RU")
{
FirstName.AllowBlank = false;
LastName.AllowBlank = false;
Company.AllowBlank = true;
Email.AllowBlank = true;
}

if (Lang == "en-US")
{
FirstName.AllowBlank = false;
LastName.AllowBlank = false;
Company.AllowBlank = false;
Email.AllowBlank = false;
}
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>FormPanel Validation - Ext.NET Examples</title>
<style>
.icon-exclamation {
padding-left: 25px !important;
background: url(/icons/exclamation-png/ext.axd) no-repeat 3px 0px !important;
}

.icon-accept {
padding-left: 25px !important;
background: url(/icons/accept-png/ext.axd) no-repeat 3px 0px !important;
}
</style>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:Panel
runat="server"
Layout="FitLayout"
Width="600"
Height="250">
<Items>
<ext:FormPanel
ID="FormPanel1"
runat="server"
Title="FormPanel Validation (all fields required)"
BodyPadding="5"
ButtonAlign="Right"
Layout="Column">
<Items>
<ext:Panel
runat="server"
Border="false"
Header="false"
ColumnWidth=".5"
Layout="Form"
LabelAlign="Top">
<Items>
<ext:TextField runat="server" ID="FirstName" FieldLabel="First Name" AnchorHorizontal="92%" />
<ext:TextField runat="server" ID="Company" FieldLabel="Company" AnchorHorizontal="92%" />
</Items>
</ext:Panel>
<ext:Panel runat="server" Border="false" Layout="Form" ColumnWidth=".5" LabelAlign="Top">
<Items>
<ext:TextField runat="server" ID="LastName" FieldLabel="Last Name" AnchorHorizontal="92%" />
<ext:TextField runat="server" ID="Email" FieldLabel="Email" Vtype="email" AnchorHorizontal="92%" />
</Items>
</ext:Panel>
</Items>
<BottomBar>
<ext:StatusBar runat="server" />
</BottomBar>
<Listeners>
<ValidityChange Handler="this.dockedItems.get(1).setStatus({
text : valid ? 'Form is valid' : 'Form is invalid',
iconCls: valid ? 'icon-accept' : 'icon-exclamation'
});
#{Button1}.setDisabled(!valid);" />
</Listeners>
</ext:FormPanel>
</Items>
<Buttons>
<ext:Button
ID="Button1"
runat="server"
Text="Save"
Disabled="true"
FormBind="true">
<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>
</ext:Panel>
</form>
</body>
</html>