Dynamic Validation

Posted by Shivanichhabra4u under ASP.NET on 2/10/2009 | Views : 1512 | Status : [Member] | Replies : 1
I have the follwing code, this is generating dynamically textboxes and requirefield validators
But it is not doing validation , it is giving "System.NullReferenceException: Object reference not set to an instance of an object."
error.
Please help me out as soon as possible
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim item As Integer
For item = 0 To 5
Dim txtDescription As New TextBox()
txtDescription.ID = "txtDescription" & item
txtDescription.Text = "Desc Shivani" & item
'txtDescription.Width = Unit.Point(35)
txtDescription.MaxLength = 50
Dim colDescription As New TableCell()
colDescription.HorizontalAlign = HorizontalAlign.Left
colDescription.VerticalAlign = VerticalAlign.Top
Dim rowDescription As New TableRow()
colDescription.Controls.Add(txtDescription)
rowDescription.Cells.Add(colDescription)

Dim rvDescription As New RequiredFieldValidator()
rvDescription.ControlToValidate = "txtDescription" & item
rvDescription.Display = ValidatorDisplay.Dynamic
rvDescription.ErrorMessage = "Please enter a Description."
rvDescription.ID = "rvDescription" & item
Page.Validators.Add(rvDescription)
Next
End Sub




Responses

Posted by: Raja on: 2/11/2009 [Member] Starter

Up
0
Down
See this it may help you http://www.velocityreviews.com/forums/t120566-dynamic-form-not-validating-on-server.html

Thanks

Regards,
Raja, USA

Shivanichhabra4u, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response