ValidationProperty

  • Thread starter =?ISO-8859-1?Q?S=E9bastien_Decoux?=
  • Start date
?

=?ISO-8859-1?Q?S=E9bastien_Decoux?=

Hi !

I have a problem with a Web User Control who does not trigger the
RequiredFieldValidator Control...

I created a Web User COntrol who contain a TextBox. I created a property
to obtain and set the Text property of the TextBox, making it visible
outside of the control. I called this property "Text". (Originality,
Welcome)

Here's the code of the property :

[Bindable(true)]
[Description("Obtain or set the value insode the TextBox")]
[Category("Appearance")]
[DefaultValue("")]
public string Text
{
get
{
EnsureChildControls();
return this.txtDate.Text;
}
set
{
EnsureChildControls();
this.txtDate.Text = value;
}
}

Next, I wanted to be able to validate my control, wiwh means he can
trigger the validation controls (RequireFieldValidator,
RegularExpressionValidator,...)

I modified the declaration of my class to this :

[DefaultProperty("Text")]
[ValidationProperty("Text")]
[Designer(typeof(Designers.DatePickerDesigner))]
[ToolboxData("<{0}:DatePicker runat=server></{0}:DatePicker>")]
[ToolboxBitmap(typeof(System.Web.UI.WebControls.TextBox))]
public class DatePicker : System.Web.UI.WebControls.WebControl

The problem is every single validation controls works fine (Compare,
RegularExpression, Range, Custom), except the RequiredFieldValidator...

Anybody has an idea ?
 
?

=?ISO-8859-1?Q?S=E9bastien_Decoux?=

I can bring new data... My control is validated, but only server-side
(the RequiredFieldValidator is the only Validation Control who doesn't
trigger client side on my control)... As my control is located on a form
containing other validators triggerd Client side, this is annoying to
have the error message displayed only after the PostBack.

Could these new data give ideas to someone ?


Sébastien Decoux wrote :
Hi !

I have a problem with a Web User Control who does not trigger the
RequiredFieldValidator Control...

I created a Web User COntrol who contain a TextBox. I created a property
to obtain and set the Text property of the TextBox, making it visible
outside of the control. I called this property "Text". (Originality,
Welcome)

Here's the code of the property :

[Bindable(true)]
[Description("Obtain or set the value insode the TextBox")]
[Category("Appearance")]
[DefaultValue("")]
public string Text
{
get
{
EnsureChildControls();
return this.txtDate.Text;
}
set
{
EnsureChildControls();
this.txtDate.Text = value;
}
}

Next, I wanted to be able to validate my control, wiwh means he can
trigger the validation controls (RequireFieldValidator,
RegularExpressionValidator,...)

I modified the declaration of my class to this :

[DefaultProperty("Text")]
[ValidationProperty("Text")]
[Designer(typeof(Designers.DatePickerDesigner))]
[ToolboxData("<{0}:DatePicker runat=server></{0}:DatePicker>")]
[ToolboxBitmap(typeof(System.Web.UI.WebControls.TextBox))]
public class DatePicker : System.Web.UI.WebControls.WebControl

The problem is every single validation controls works fine (Compare,
RegularExpression, Range, Custom), except the RequiredFieldValidator...

Anybody has an idea ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top