Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

validation fails when moving controls

Status
Not open for further replies.

wanmaster

Programmer
Nov 20, 2000
94
NL
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):

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top