473,770 Members | 4,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ivalidator and Validation Groups

Here is a question that needs to be revisited. I noticed that there are
more that a few posts about this in this group and in custom controls.
Here is the problem:
When inheriting from a webcontrol, say textbox for example, and
implementing the IValidator interface to make the control
self-validating, the control fails to participate in validation groups.
Using reflector, it is easy to see why; the page.validator casts all
the controls in the collection to BaseValidator, thus a control derived
from a TextBox implementing IValidator gets cast to Nothing (Null).
However all the correct attributes and abilities are there. So the
question that still remains unanswered by all the .NET gurus in this
group is-- How can a control created as aformentioned be forced to
participate in the validation groups of ASP.Net 2.0?

Some thoughts of mine are: Cast the control myself using a custom type
caster?? Is this possible?
Perhaps I could create a basevalidator object in my control and using
delegates have it still fire my Validate() function of my control and
modify the isValid property and display the message i have set up.
This seems very complicated and riddled with opportunities for even
greater obsticals that the one I am trying to overcome.
Use a composit control that includes a custom validator derived from
BaseValidator. This is the most strait foward for the validation
groups, but complicates the rest of the control.
To see the code used for my Textbox self validating control, look at my
forums http://forums.atechinnovations.com/viewtopic.php?t=22

Jul 31 '06 #1
1 3194
See my reply on ASP.NET Forums:
http://forums.asp.net/1357685/ShowThread.aspx#1357685

Shortly: You can override Page.Validate method

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

"brantman" <br***@cableone .netwrote in message
news:11******** **************@ i42g2000cwa.goo glegroups.com.. .
Here is a question that needs to be revisited. I noticed that there are
more that a few posts about this in this group and in custom controls.
Here is the problem:
When inheriting from a webcontrol, say textbox for example, and
implementing the IValidator interface to make the control
self-validating, the control fails to participate in validation groups.
Using reflector, it is easy to see why; the page.validator casts all
the controls in the collection to BaseValidator, thus a control derived
from a TextBox implementing IValidator gets cast to Nothing (Null).
However all the correct attributes and abilities are there. So the
question that still remains unanswered by all the .NET gurus in this
group is-- How can a control created as aformentioned be forced to
participate in the validation groups of ASP.Net 2.0?

Some thoughts of mine are: Cast the control myself using a custom type
caster?? Is this possible?
Perhaps I could create a basevalidator object in my control and using
delegates have it still fire my Validate() function of my control and
modify the isValid property and display the message i have set up.
This seems very complicated and riddled with opportunities for even
greater obsticals that the one I am trying to overcome.
Use a composit control that includes a custom validator derived from
BaseValidator. This is the most strait foward for the validation
groups, but complicates the rest of the control.
To see the code used for my Textbox self validating control, look at my
forums http://forums.atechinnovations.com/viewtopic.php?t=22

Aug 1 '06 #2

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

Similar topics

2
1149
by: Ing. Rajesh Kumar | last post by:
Hi everybody Validation controls are great but i have a scenario where i do not know how to use them so i am doing my validation on the server. Let's say I have a Web Form with : Two Textboxes : Textbox_1, Textbox_2 Two Checkboxes : Checkbox_1, Checkbox_2 A Button : btnSubmit What I want is : If Checkbox_1 is checked then Textbox_1 is required and it should contain
3
2831
by: john morales | last post by:
Hi guys, I have a problem and i know there must be a solution for this as it is such a basic common practice in asp.net development. Scenario: i have many webforms in a site, most with two different custom controls, one is a login module, the other is a generic data entry module. When there are no validation controls on the page there is no problem. But when the the data entry module has validation controls, the login module triggers...
0
1660
by: Martin | last post by:
Hi, I wanted to preform my own custom validation for the entire page so i though I would implemet the IValidator interface and do all of my validation in the "Validate" method, and this works well with one small problem. The "Page" class has a property called "IsValid" which is read-only. IValidator implements a private variable called isvalid
4
2976
by: David Colliver | last post by:
Hi all, I am having a slight problem that hopefully, someone can help me fix. I have a form on a page. Many items on the form have validation controls attached. Also on this form are linkbuttons which must not cause validation. I have found a setting "causeValidation" to disable the validation. Also on the page, I have a datagrid that I will edit lines on. I can click
1
1503
by: MattC | last post by:
I have a user control that contains several requiredFieldValidators. The page the control sits in has other RequiredFieldValidators. On submitting the form all the validators on the page fire and correctly validate. The validators in the control seem to validate but do not return true/IsValid as so my form is not submitted. I would like to do this ClientSide, the only resolution I can find is to perform the validation for the...
0
1346
by: A.J. van der Burg | last post by:
Hi all, I have a serious problem with asp.net validation: I developed a custom validation summary control, which will lookup error messages from an external source based on the BaseValidator.ErrorMessage property. This validation summary control has a custom method which will add a dummy validator (which will always evaluate to false) to the Page.Validators collection. The dummy validator implements the IValidator interface, and this...
4
2710
by: ibiza | last post by:
Hi all, I have a small question concerning asp.net 2.0 validation groups. I have this (simplified) situation : Name Value _____ _____ |_____| |_____| _____ _____ |_____| |_____|
1
3825
by: misiek | last post by:
Hi all. I have following problem: I have some user control called smallUserContrl, in which I have two RangeValidator controls. I set their ValidationGroup property to smallUserControlGroup. Also I have another user control called bigUserControl, in which I use smallUserControl. BigUserControl also has some validator, which has ValidationGroup property set to bigUserControlGroup.
1
1230
by: Velvet | last post by:
Does anyone know a way to force the client script to preform a client-side validation for controls in validation groups? What is currently happening is I have two validation groups (Billing, CreditCard). The validation doesn't happen until the submit button is pressed and the server validation happens. I added an OnClickClient event to the submit button that pops up a comfirm box, but it pops before any validation happens. What I...
0
9439
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10237
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10071
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9882
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5326
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2832
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.