473,473 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

validating dynamically generated textboxes

HI Gurus. I am trying to generate a Table with dynamic controls in different
cells. I am at the same time generating Validation controls and assigning
"control to validate" property to the ID of the generated controls. The
generation works as expected, however when I press the submit button,
validation controls do not react. I posted the code below for the entire
table. In the last line I add the table to a session and regenerate the table
in the Page_Init between postbacks. Can anyone suggest why the validation
does not fire? BTW the "Causesvalidation" property of the submit button is
"ON". In advance, many thanks.

For counter = 0 To CInt(qty - 1)
tRow = New HtmlTableRow
tRow.ID = "fltRow" & counter

'mile cells
tCell = New HtmlTableCell
tCell.ID = "cellMile" & counter
tCell.Width = "20px"
txbMile = New TextBox
txbMile.ID = "txbMile" & counter
validator = New RangeValidator
validator.ControlToValidate = "txbMile" & counter
validator.Type = ValidationDataType.Integer
validator.MinimumValue = txbStartMile.Text
validator.MaximumValue = txbEndMile.Text
validator.Text = "*"
validator.ErrorMessage = "The value must be between " &
txbStartMile.Text & " and " & txbEndMile.Text
txbMile.Width = New System.Web.UI.WebControls.Unit(30)
tCell.Controls.Add(txbMile)
tCell.Controls.Add(validator)
tRow.Cells.Add(tCell)

'chain Cells
tCell = New HtmlTableCell
tCell.ID = "cellChan" & counter
tCell.Width = "20px"
txbchain = New TextBox
validator = New RangeValidator
validator.Type = ValidationDataType.Integer
validator.ControlToValidate = "cellChan" & counter
validator.MinimumValue = txbStartYards.Text
validator.MaximumValue = txbEndYards.Text
validator.Text = "*"
validator.ErrorMessage = "The value must be between " &
txbStartYards.Text & " and " & txbEndYards.Text
txbchain.Width = New System.Web.UI.WebControls.Unit(30)
txbchain.ID = "txbChain" & counter
tCell.Controls.Add(txbchain)
tRow.Cells.Add(tCell)

'fault Cells
tCell = New HtmlTableCell
tCell.ID = "cellFault" & counter
tCell.Width = "80%"
' validator = New RangeValidator
txbFault = New TextBox
txbFault.ID = "txbFault" & counter
recValidator = New RequiredFieldValidator
recValidator.ControlToValidate = "txbFault" & counter
recValidator.Text = "*"
recValidator.ErrorMessage = "Please add the fault"
txbFault.Wrap = True
txbFault.TextMode = TextBoxMode.MultiLine
txbFault.Width = New System.Web.UI.WebControls.Unit(400)
tCell.Controls.Add(txbFault)
tRow.Cells.Add(tCell)
'add created row to the table
tableFaults.Rows.Add(tRow)
Next
tableFaults.Width = "100%"
tableFaults.Border = "1"
tableFaults.ID = "tblFaults"
pnlFaults.Controls.Add(tableFaults)
Session("tableFaults") = tableFaults
Dec 6 '05 #1
0 898

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

Similar topics

4
by: EmmettPower | last post by:
Hi, I have a form which includes a field 'number'. When 'number' is changed additional fields ('item_0', etc) are generated on the form using 'onchange'. I want to validate the form using...
1
by: panche | last post by:
I'm developing a fairly simple user control that has two textboxes for date/time entry (a from date/time and a to date/time). One of my requirements is that there should be no button that sets...
5
by: Will Lastname | last post by:
I'm working on administration panel that will ultimately allow the client to edit products in a collection. Each ProjectList can have multiple products within it. I was asked to create something...
0
by: Matthew | last post by:
All, I have searched google and the newsgroups but can't find anything the same as what I am experiencing (though I may have missed something). I have controls (textboxes) within UserControls...
6
by: Ryan | last post by:
I have a windows form that I want to force validation on controls (text boxes) when the user clicks a "Save" button. The only way I've found to do this is to cycle through every control and call...
9
by: netasp | last post by:
hi all, how can I populate one aspx form when page is loading based on page ID? for example: loading page A (to search for VB code) would display labels and texboxes, dropdown lists all related...
6
by: Bjorn Sagbakken | last post by:
Hello In VS2005: I am adding buttons and textboxes dynamically into a table, that also dynamically expands. So far, so good, actually very nice. But I am having trouble starting the desired...
8
by: clintonG | last post by:
I have to get to this later tonight or tommorrow...and wonder... There's two TextBoxes in a Wizard Step posing an either-or situtation. Only one or the other TextBox may pass data. The...
0
by: rvdnieuwenhuizen | last post by:
Hi, The problem I cannot seem to solve: I have a page with a button control. In the On_Click eventhandler I dynamically add one TextBox each time the button is clicked. I add the textboxes to...
0
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...
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,...
0
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...
1
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
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...
0
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...

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.