I've made a basic page that handles all common functionality and design. All pages in the project derive from this page, and contain only some server side controls and text (no form, no head or body tags etc.).
This content is 'moved' to the basic page in the Init() event.
This all works fine, except for one thing: the validation does no longer work. No errors are raised, it just ignores the validation part (Page.Validate(), Page.IsValid).
I' have analyzed the problem, and it seems that the problem has something to do when I move the controls from one collection to another.
Here it is (I've removed some irrelevant bits from the source code):
Any suggestions?
Remedy
This content is 'moved' to the basic page in the Init() event.
This all works fine, except for one thing: the validation does no longer work. No errors are raised, it just ignores the validation part (Page.Validate(), Page.IsValid).
I' have analyzed the problem, and it seems that the problem has something to do when I move the controls from one collection to another.
Here it is (I've removed some irrelevant bits from the source code):
Code:
Private moForm As HtmlForm
Private Sub AddRightDivision(ByVal ParentCollection As ControlCollection)
Dim loCtrl As Control
(....)
'copy existing controls (from derived page)
While (Me.Controls.Count > 0)
loCtrl = Me.Controls(0)
ParentCollection.Add(loCtrl)
Me.Controls.Remove(loCtrl)
End While
(....)
End Sub
Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
(....)
'create form
moForm = New HtmlForm()
moForm.ID = "frmMain"
'assemble form
(....)
AddDivisionRight(moForm.Controls)
'assemble page
(....)
Me.Controls.Add(moForm)
(....)
'continue
MyBase.OnInit(e)
End Sub
Any suggestions?
Remedy