// [ControlBuilder (typeof(MultiViewControlBuilder)]
[Designer ("System.Web.UI.Design.WebControls.MultiViewDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
[ToolboxData ("<{0}:MultiView runat=\"server\"></{0}:MultiView>")]
- [ParseChildren (false, ChildControlType = typeof(View))]
+#if NET_2_0
+ [ParseChildren (typeof(View))]
+#else
+ [ParseChildren (false)]
+#endif
[DefaultEvent ("ActiveViewChanged")]
public class MultiView: Control
{
public static readonly string SwitchViewByIDCommandName = "SwitchViewByID";
public static readonly string SwitchViewByIndexCommandName = "SwitchViewByIndex";
- private static readonly object ActiveViewChangedEvent = new object();
+ static readonly object ActiveViewChangedEvent = new object();
int viewIndex = -1;
int initialIndex = -1;
- bool initied = false;
public event EventHandler ActiveViewChanged {
add { Events.AddHandler (ActiveViewChangedEvent, value); }
{
if (ob is View)
Controls.Add (ob as View);
- else
- throw new HttpException ("MultiView cannot have children of type 'Control'. It can only have children of type View.");
+ // LAMESPEC: msdn talks that only View contorls are allowed, for others controls HttpException should be thrown
+ // but actually, aspx praser adds LiteralControl controls.
+ //else
+ // throw new HttpException ("MultiView cannot have children of type 'Control'. It can only have children of type View.");
}
protected override ControlCollection CreateControlCollection ()
public virtual int ActiveViewIndex {
get
{
- if (!initied)
+ if (Controls.Count == 0)
return initialIndex;
return viewIndex;
}
set
{
- if (!initied) {
+ if (Controls.Count == 0) {
initialIndex = value;
return;
}
((View)Controls [viewIndex]).NotifyActivation (true);
UpdateViewVisibility ();
+
+ OnActiveViewChanged (EventArgs.Empty);
}
}
[Browsable (true)]
- [MonoTODO]
public virtual new bool EnableTheming
{
- get {
- throw new NotImplementedException ();
- }
- set {
- throw new NotImplementedException ();
- }
+ get { return base.EnableTheming; }
+ set { base.EnableTheming = value; }
}
[PersistenceMode (PersistenceMode.InnerDefaultProperty)]
protected internal override void OnInit (EventArgs e)
{
- initied = true;
Page.RegisterRequiresControlState (this);
if (initialIndex != -1) {
ActiveViewIndex = initialIndex;
protected internal override void Render (HtmlTextWriter writer)
{
- if (!initied) viewIndex = initialIndex;
+ if ((Controls.Count == 0) && (initialIndex != -1))
+ viewIndex = initialIndex;
if (viewIndex != -1)
GetActiveView ().Render (writer);
}