Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Creating Validators in Custom ASP.NET Server Controls

Reply
Thread Tools

Creating Validators in Custom ASP.NET Server Controls

 
 
=?Utf-8?B?TWlndWVsIElzaWRvcm8=?=
Guest
Posts: n/a
 
      07-27-2006
Hi all,

I am developing a Custom ASP.NET Server Controls that generates a form based
on a xml file and want to include RequiredFieldValidator for mandatory
questions. I am using the following function:

private RequiredFieldValidator CreateRequiredFieldValidator(string
controlToValidateID, string errorMessage)
{
RequiredFieldValidator requiredFieldValidator = new
RequiredFieldValidator();
requiredFieldValidator.ControlToValidate = controlToValidateID;
requiredFieldValidator.Display = ValidatorDisplay.Dynamic;
requiredFieldValidator.ErrorMessage = errorMessage;

return requiredFieldValidator;
}

Everytime I want to include a requiredfieldvalidator i call this function as
follows:

RequiredFieldValidator requiredFieldValidator =
CreateRequiredFieldValidator(controlID, "Required field");
responsePanel.Controls.Add(requiredFieldValidator) ;

The responsePanel is a Panel control that maps to a html <div> element. I
leave the EnableClientScript enabled so that I can see the javascript code
that is generated. I saw the html source that is generated and it seems ok
and the ControlToValidate property is properly set with the right ids. All
the javascript functions are there or are in the included WebResource.axd
http handler. I even tried to set the EnableClientScript property to false
and it doesn't work also.

Any sugestions?

Thanks
Miguel
 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      07-27-2006
Hi,

can you clarify a bit how it doesn't work? Can you also show a bit more code
how you are using it in scenario where it fails?


--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

"Miguel Isidoro" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi all,
>
> I am developing a Custom ASP.NET Server Controls that generates a form
> based
> on a xml file and want to include RequiredFieldValidator for mandatory
> questions. I am using the following function:
>
> private RequiredFieldValidator CreateRequiredFieldValidator(string
> controlToValidateID, string errorMessage)
> {
> RequiredFieldValidator requiredFieldValidator = new
> RequiredFieldValidator();
> requiredFieldValidator.ControlToValidate = controlToValidateID;
> requiredFieldValidator.Display = ValidatorDisplay.Dynamic;
> requiredFieldValidator.ErrorMessage = errorMessage;
>
> return requiredFieldValidator;
> }
>
> Everytime I want to include a requiredfieldvalidator i call this function
> as
> follows:
>
> RequiredFieldValidator requiredFieldValidator =
> CreateRequiredFieldValidator(controlID, "Required field");
> responsePanel.Controls.Add(requiredFieldValidator) ;
>
> The responsePanel is a Panel control that maps to a html <div> element. I
> leave the EnableClientScript enabled so that I can see the javascript code
> that is generated. I saw the html source that is generated and it seems ok
> and the ControlToValidate property is properly set with the right ids. All
> the javascript functions are there or are in the included WebResource.axd
> http handler. I even tried to set the EnableClientScript property to false
> and it doesn't work also.
>
> Any sugestions?
>
> Thanks
> Miguel



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
databound custom controls vs composite databound custom controls rodchar ASP .Net 0 11-26-2007 03:51 PM
Using validators on custom controls shodson@gmail.com ASP .Net Web Controls 0 06-24-2005 06:32 PM
dynamically creating controls, validators, using autopost back =?Utf-8?B?TFU=?= ASP .Net 3 03-30-2005 01:21 PM
How to use custom validators for dynamically genrated textboxes Charith Jayasundara via .NET 247 ASP .Net 2 03-23-2005 01:51 PM
Regular Expression validators NOT working, Required Field validators ARE working Ratman ASP .Net 0 09-14-2004 09:36 PM



Advertisments