Basic Usage of MultiView and View Controls in ASP.NET - Container Properties of View and MultiView Controls
(Page 4 of 5 )
Just as you can access the properties of controls in forms in Visual Basic, or controls in the <form/> of a web page, you can access the controls placed in the View control and the Views placed in the MultiView control programmatically. This is done as shown in the next snippet for the design view shown here.

Protected Sub MultiView1_Load(ByVal sender As Object, ByVal e _
As System.EventArgs) Handles MultiView1.Load
'This displays the view
MultiView1.SetActiveView(View1)
Response.Write("Number of View Controls in this MultiView : " & _
MultiView1.Controls.Count & "<br>")
Response.Write("Number of controls in the View control" & _
"whose index is 0 : " & _
MultiView1.Controls(0).Controls.Count & "<br>")
Response.Write("Type of Control in View1 with index 0 : " & _
MultiView1.Controls(0).Controls(0).GetType.ToString & "<br>")
Response.Write("Type of Control in View1 with index 1 : " & _
MultiView1.Controls(0).Controls(1).GetType.ToString & "<br>")
Response.Write("Type of Control in View1 with index 2 : " & _
MultiView1.Controls(0).Controls(2).GetType.ToString & "<br>")
Response.Write("Type of Control in View1 with index 3 : " & _
MultiView1.Controls(0).Controls(3).GetType.ToString & "<br>")
Response.Write("Type of Control in View1 with index 4 : " & _
MultiView1.Controls(0).Controls(4).GetType.ToString & "<br>")
Response.Write("Type of Control in View1 with index 5 : " & _
MultiView1.Controls(0).Controls(5).GetType.ToString & "<br>")
End Sub
The displayed output of this web page is shown in the next picture. Although there are three controls in View1, there are six controls in the display, with three extra Literal controls. The page has two View controls. The controls and the Views can access their containers using the parent property.

Once you access the control you may control its properties using the code support given by intellisense as shown.

Next: Presenting a user preferred View >>
More .NET Articles
More By Jayaram Krishnaswamy