PDA

View Full Version : Adding fieldset and controls from codebehind / TextBoxes are not firing validation



GrZeCh
Mar 01, 2008, 2:31 PM
Hello!

There is problem when I have placeholder in .aspx file and in codebehind I'm creating coolite FieldSet, few labels (and add them to created FieldSet) and after this I add this fieldset to placeholder. Fieldset and labels are showing but labels are outside fieldset.

When I use coolite TextBox and try to validate it using default validation controls validation is not firing.

Thanks

geoffrey.mcgill
Mar 03, 2008, 12:46 AM
Hi GrZeCh,

Can you provide us with a code sample demonstrating how you are adding the controls to the FieldSet?

You also mentioned the validation. Do you mean the standard asp validation controls? or the built in validation functionality of the <cool:TextBox>?

GrZeCh
Mar 15, 2008, 7:26 AM
<cool:TextBox ID="TextBox2" runat="server"></cool:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" ValidationGroup="Webowe" runat="server" ErrorMessage="Pole wymagane" ControlToValidate="TextBox2"></asp:RequiredFieldValidator>

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ValidationGroup="Webowe" runat="server" ErrorMessage="Pole wymagane" ControlToValidate="TextBox1"></asp:RequiredFieldValidator>


Try something like this (add button for submit after this). Validation is only fired for "normal" textbox (without postback).

geoffrey.mcgill
Mar 28, 2008, 4:57 PM
ya, this is a bit of a problem. I also just noticed that the coolite Button control is not causing the Validation events to trigger. This is something we're going to try and get working for the next release.

The Coolite TextBox control includes an internal validation mechanism that you might find helpful. There are several validation related properties which include:
AllowBlank MaxLength MinLength Regex = A RegularExpression to be tested against the field value. Return true if valid, otherwise a string error message if validation fails. Validator = A custom JavaScript function which will fire. Return true if valid, otherwise a string error message if validation fails.

Example


<cool:TextBox
ID="TextBox1"
runat="server"
AllowBlank="false"
/>