473,795 Members | 2,630 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamically generating control validators

I'm developing a custom server control that will be rendering a form based
on some input. I've tried creating custom validators in vb.net like so:

Dim v1 as RequiredValidat or = new RequiredValidat or()
Dim vs as ValidationSumma ry = new ValidationSumma ry()

RequiredValidat or.ControlToVal idate = "id of form control here"
RequiredValidat or.Enabled = True
RequiredValidat or.EnableClient Script = True
RequiredValidat or.ErrorMessage = "Test message"

ValidationSumma ry.ShowSummary = False
ValidationSumma ry.ShowMessageB ox = True
ValidationSumma ry.EnableClient Script = True
ValidationSumma ry.Enabled = True
Now when I submit the form, I have a piece of code in the button's onclick
event that does:

Response.Write "Page Validity: " & Me.IsValid

When the fields are not filled in properly, me.IsValid returns false as
expected, but the ValidationSumma ry never displays the messagebox. It's
almost like the validation controls have to be registered with the
validation summary somehow, and that's not happening.

Any ideas? What am I missing?
Thanks in advance,
Chris

--
Insert corny line here
Nov 17 '05 #1
2 2545
How about
Page.Controls.A dd( vs );

-=Chris=- wrote:
I'm developing a custom server control that will be rendering a form based
on some input. I've tried creating custom validators in vb.net like so:

Dim v1 as RequiredValidat or = new RequiredValidat or()
Dim vs as ValidationSumma ry = new ValidationSumma ry()

RequiredValidat or.ControlToVal idate = "id of form control here"
RequiredValidat or.Enabled = True
RequiredValidat or.EnableClient Script = True
RequiredValidat or.ErrorMessage = "Test message"

ValidationSumma ry.ShowSummary = False
ValidationSumma ry.ShowMessageB ox = True
ValidationSumma ry.EnableClient Script = True
ValidationSumma ry.Enabled = True
Now when I submit the form, I have a piece of code in the button's onclick
event that does:

Response.Write "Page Validity: " & Me.IsValid

When the fields are not filled in properly, me.IsValid returns false as
expected, but the ValidationSumma ry never displays the messagebox. It's
almost like the validation controls have to be registered with the
validation summary somehow, and that's not happening.

Any ideas? What am I missing?
Thanks in advance,
Chris


--
bill
e-mail: bi*****@hotmail .com
MSN Messenger: bi*****@hotmail .com
Web: http://www.minivoice.com

Nov 17 '05 #2
No dice. I even tried adding the summary control through the IDE using
drag/drop to make sure it was registered. Still no message.

I was minding my own business when bill blurted out:
How about
Page.Controls.A dd( vs );

-=Chris=- wrote:
I'm developing a custom server control that will be rendering a form based on some input. I've tried creating custom validators in vb.net like so:

Dim v1 as RequiredValidat or = new RequiredValidat or()
Dim vs as ValidationSumma ry = new ValidationSumma ry()

RequiredValidat or.ControlToVal idate = "id of form control here"
RequiredValidat or.Enabled = True
RequiredValidat or.EnableClient Script = True
RequiredValidat or.ErrorMessage = "Test message"

ValidationSumma ry.ShowSummary = False
ValidationSumma ry.ShowMessageB ox = True
ValidationSumma ry.EnableClient Script = True
ValidationSumma ry.Enabled = True
Now when I submit the form, I have a piece of code in the button's onclick event that does:

Response.Write "Page Validity: " & Me.IsValid

When the fields are not filled in properly, me.IsValid returns false as
expected, but the ValidationSumma ry never displays the messagebox. It's
almost like the validation controls have to be registered with the
validation summary somehow, and that's not happening.

Any ideas? What am I missing?
Thanks in advance,
Chris


--
Insert corny line here
Nov 17 '05 #3

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

Similar topics

0
1339
by: Trillium | last post by:
I am trying to upgrade a straight ASP project into .NET, but I am new at ..NET, and there seem to be so many different ways to do things. I am new to ..NET and need some guidance as to which approach to take. My application is to collect answers to an indeterminate number of questions, which are defined in a database. The definition includes the question content, type of control and validation for the data. In ASP, the application...
2
3921
by: Pham Nguyen | last post by:
Has anyone seen an example of a textbox server control that has built-in client-side validation? I'd like to build a server control that extends the System.Web.UI.WebControls.TextBox class to allow javascript checks for things like valid e-mail addresses or phone numbers (without having to add a separate control for validation). One idea I did some work on was having the control implement the IValidator interface and basically recreating...
7
2875
by: A.M | last post by:
Hi, I have a validation control in my page that upon any invalid data, it disables all buttons in the page. basicly i don't have any postback in the page if the validator finds any error. How can have the validator just disable certain control's postback and other part of page continue their functionality. Thanks,
1
4726
by: Jack | last post by:
Hi, I have a page with a repeater control that contains textboxes. I'm trying to create a validation class that is called by my page. A method in this class iterates through all the controls on the page. On encountering a TextBox control, it looks at the ID to discern the field the TextBox represents, and then creates the appropriate validation controls and adds them to the page. The controlToValidate property of each validation...
1
2065
by: Jeffrey Todd | last post by:
I have successfully created functionality that mostly models what I'm trying to do - which is dynamically insert controls into a user control (ascx), and insert validation controls, also dynamically, for some of the inserted controls. The controls (e.g., textBoxes) get created correctly and viewstate is maintained across postbacks, etc - BUT there is an issue with the validation controls. The validation controls, themselves are...
1
1454
by: Chad Smith | last post by:
Hi. I have an asp.net web application written in C# which creates a datasource consisting of a Name and a list of permissable Values. This datasource is then bound to a simple repeater, the Name being bound to a label and the Values being bound to a DropDownList. All works fine. The next thing I wished to do was tap into the ItemDataBound event to add a generic "Please Select..." item to each DropDownList, with a value of "0". From...
6
11082
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to how those properties are set. I want to be able to do two other things: a) add User control instances to my page, filling in the place of placeholder controls, and b) programmatically setting custom properties on those dynamically spawned...
0
1230
by: krish | last post by:
hi, I am dynamically generating Imagebutton (say 5 imagebutton, in loop) . for each imagebutton url , i am dynamically generating image and assigining to it. every thing is ok upto this stage. The problem arises when i click on particular image button
0
1884
by: Aswanth | last post by:
I'm Working with Asp.Net with C#.. & I'm Generating Reports in SSRS-2005.. Till Now I'm Generating Reports in SSRS-2005 with Stored Procedure.. in Which I'm Generating Reports for One Particular User Details(ie I wrote Stored Procedure for Getting One Users Details).. Now I Want to Generate the Reports for Different Users DYNAMICALLY (Here, I wrote another Stored Procedure which contains UsersID's as Input...
0
9672
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
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
10438
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
10001
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...
1
7540
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6780
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
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
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.