int viewIndex = -1;
int initialIndex = -1;
- bool initied;
public event EventHandler ActiveViewChanged {
add { Events.AddHandler (ActiveViewChangedEvent, value); }
{
if (ob is View)
Controls.Add (ob as 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 ()
[DefaultValue (-1)]
public virtual int ActiveViewIndex {
- get { return viewIndex; }
- set {
- if (!initied) {
+ get
+ {
+ if (Controls.Count == 0)
+ return initialIndex;
+
+ return viewIndex;
+ }
+ set
+ {
+ if (Controls.Count == 0) {
initialIndex = value;
return;
}
case "SwitchViewByID":
foreach (View v in Controls)
- if (v.ID == ca.CommandArgument) {
+ if (v.ID == (string)ca.CommandArgument) {
SetActiveView (v);
break;
}
protected internal override void OnInit (EventArgs e)
{
- initied = true;
Page.RegisterRequiresControlState (this);
if (initialIndex != -1) {
ActiveViewIndex = initialIndex;
void UpdateViewVisibility ()
{
for (int n=0; n<Views.Count; n++)
- Views [n].Visible = (n == viewIndex);
+ Views [n].VisibleInternal = (n == viewIndex);
}
protected internal override void RemovedControl (Control ctl)
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);
}