473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Creating Validators in Custom ASP.NET Server Controls

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 <divelement. 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
Jul 27 '06 #1
1 1091
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" <Mi***********@discussions.microsoft.comwrote in message
news:06**********************************@microsof t.com...
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 <divelement. 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

Jul 27 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tom Pearson | last post by:
I create controls and validators dynamically dependent on data at runtime. I create the control then the relevant validator(s) for it assigning the Control.ID as the control to validate. These...
3
by: Christer | last post by:
Hi all! I recently created a MessageBox webcontrol for asp.net. This can be used as is, but I also want to take ude of it in other webcontrols. Right now i creating a ValidationSummary control,...
6
by: Mark | last post by:
We have Validators embedded in an asp table server control. The table server control is necessary and cannot be replaced. We want to apply CSS formatting to the validators, but the validators...
3
by: John Blair | last post by:
Hi, I have validators outside of a datagrid (for adding a new grid row) - however when i click "edit" column and then the "update" column of a grid row that has been edited - my other...
1
by: Jason | last post by:
I am able fire my field validators in FireFox on the server side using... Page.Validate() If Not Page.IsValid Then Exit Sub End If But the it won't fire Custom Validators. Anybody know why?
5
by: Suhas Vengilat | last post by:
Hi All, In one of the project discussions, one team member raised a question whether the usage of asp.net validation controls (like RequiredFieldValidator, CustomValidator, RegularExpression...
4
by: Rick | last post by:
Hello, I built a composite web control that has a textbox and a date control. added my custom control on a webform where there are other standard controls. Each control on the form has a...
1
by: Andrew Jocelyn | last post by:
Hi I have a Formview control in a UserControl. The server-side validation is not working, i.e. the events are not firing when a button control which causes validation is fired or even when...
2
by: Jordan S. | last post by:
I'm experimenting with dynamically inserting custom composite Web server controls onto a page. For testing purposes I have two custom composite Web server controls that each have a couple of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.