.NETGURU
Dynamically adding validation controls
Messages   Related Types
This message was discovered on ASPFriends.com 'aspng-validators' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Vaishali DotNet
-- Copied from [aspngfreeforall] to [aspng-validators] by Charles M. Carroll <Click here to reveal e-mail address> --

Hi,
I am adding required field validation controls to the
form dynamically. It validates as expected by it never
shows the errormessage on the screen. It does prevent
post back. How do I solve this?
Thanks.
-Vaishali

__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - send holiday greetings for Easter, Passover
http://greetings.yahoo.com/

Reply to this message...
 
    
Steven A Smith (VIP)
What does it show? There are two parts that a ValidationControl may show,
its Text or its ErrorMessage. These are also affected by the presence of a
ValidationSummary control on the page. Some example code would help.

Steve

----- Original Message -----
From: "Vaishali DotNet" <Click here to reveal e-mail address>
To: "aspng-validators" <Click here to reveal e-mail address>
Sent: Friday, March 29, 2002 5:26 AM
Subject: [aspng-validators] Dynamically adding validation controls

> -- Copied from [aspngfreeforall] to [aspng-validators] by Charles M.
Carroll <Click here to reveal e-mail address> --
[Original message clipped]

Reply to this message...
 
    
Scott Cate
In writing a commercial application, I'm building everything dynamically
so the user interface is minimal.

Below is some code that I use to create textboxxes, inside my forms, and
user controls.

I'm having problems getting a validation control to work, it seems to
bind tofunctions follow the control, however doesn't seem to work
properly, the controls all get added, but I'm missing something.

Here is the code to follow.

<table created that will add this row>

EditUserTable.Rows.Add(myKBGenericFunctions.CreateEditRowTextBox("UserNa
me", "tbUserName"))
</table created that will add this row>

<CreateEditRowTextBox>
EditCell.Controls.Add(CreateTextBox(tbName, tbValue, tbLength))
</CreateEditRowTextBox>

Public Function CreateTextBox(ByVal name As String, ByVal text As
String, Optional ByVal size As Integer = 40) As TextBox
Dim TextBoxCtl As New TextBox()
TextBoxCtl.Attributes.Add("Size", size)
TextBoxCtl.ID = name
TextBoxCtl.Text = text
Return TextBoxCtl
End Function

<Commnet> This all works fine </comment>

Now the validator

Dim revUserName As New RegularExpressionValidator()
With revUserName
.ControlToValidate = "tbUserName"
.ValidationExpression = "(admin)"
.ErrorMessage = "UserName [Admin] is not allowed"
.Display = ValidatorDisplay.Dynamic
End With

And this gets added to the same placehodler control that the table got
added to.

I'm trying to check if someone is typeing in a new user names "Admin"
and prevent that from happening.

Tia
Scott

Reply to this message...
 
 
System.Web.UI.MobileControls.RegularExpressionValidator
System.Web.UI.MobileControls.TextBox
System.Web.UI.MobileControls.ValidationSummary
System.Web.UI.WebControls.RegularExpressionValidator
System.Web.UI.WebControls.TextBox
System.Web.UI.WebControls.ValidationSummary
System.Web.UI.WebControls.ValidatorDisplay
System.Windows.Forms.TextBox




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification