1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
|
//------------------------------------------------------------------------------
// <copyright file="WizardStepBase.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.WebControls {
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
public sealed class WizardStepControlBuilder : ControlBuilder {
internal override void SetParentBuilder(ControlBuilder parentBuilder) {
// Do not check containment at designtime or in a skin file.
if (Parser.FInDesigner || Parser is PageThemeParser)
return;
if (parentBuilder.ControlType == null ||
!(typeof(WizardStepCollection).IsAssignableFrom(parentBuilder.ControlType))) {
throw new HttpException(SR.GetString(SR.WizardStep_WrongContainment));
}
base.SetParentBuilder(parentBuilder);
}
}
[
Bindable(false),
ControlBuilderAttribute(typeof(WizardStepControlBuilder)),
ToolboxItem(false)
]
public abstract class WizardStepBase : View {
private Wizard _owner;
[
WebCategory("Behavior"),
Themeable(false),
Filterable(false),
DefaultValue(true),
WebSysDescription(SR.WizardStep_AllowReturn)
]
public virtual bool AllowReturn {
get {
object o = ViewState["AllowReturn"];
return o == null? true : (bool)o;
}
set {
ViewState["AllowReturn"] = value;
}
}
/// <devdoc>
/// <para>Gets and sets a value indicating whether theme is enabled.</para>
/// </devdoc>
[
Browsable(true)
]
public override bool EnableTheming {
get {
return base.EnableTheming;
}
set {
base.EnableTheming = value;
}
}
public override string ID {
get {
return base.ID;
}
set {
// VSWhidbey 407127. Need to validate control ID here since WiardStepBase does not have a designer.
if (Owner != null && Owner.DesignMode) {
if (!CodeGenerator.IsValidLanguageIndependentIdentifier(value)) {
throw new ArgumentException(SR.GetString(SR.Invalid_identifier, value));
}
if (value != null && value.Equals(Owner.ID, StringComparison.OrdinalIgnoreCase)) {
throw new ArgumentException(SR.GetString(SR.Id_already_used, value));
}
foreach (WizardStepBase step in Owner.WizardSteps) {
if (step == this) {
continue;
}
if (step.ID != null && step.ID.Equals(value, StringComparison.OrdinalIgnoreCase)) {
throw new ArgumentException(SR.GetString(SR.Id_already_used, value));
}
}
}
base.ID = value;
}
}
[
Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
WebCategory("Appearance"),
WebSysDescription(SR.WizardStep_Name)
]
public virtual String Name {
get {
if (!String.IsNullOrEmpty(Title)) {
return Title;
}
if (!String.IsNullOrEmpty(ID)) {
return ID;
}
return null;
}
}
internal virtual Wizard Owner {
get {
return _owner;
}
set {
_owner = value;
}
}
[
WebCategory("Behavior"),
DefaultValue(WizardStepType.Auto),
WebSysDescription(SR.WizardStep_StepType)
]
public virtual WizardStepType StepType {
get {
object o = ViewState["StepType"];
return o == null? WizardStepType.Auto : (WizardStepType)o;
}
set {
if (value < WizardStepType.Auto || value > WizardStepType.Step) {
throw new ArgumentOutOfRangeException("value");
}
if (StepType != value) {
ViewState["StepType"] = value;
if (Owner != null) {
Owner.OnWizardStepsChanged();
}
}
}
}
/// <devdoc>
/// <para>Gets or sets the title on the <see cref='System.Web.UI.WebControls.Wizard/> .</para>
/// </devdoc>
[
DefaultValue(""),
Localizable(true),
WebCategory("Appearance"),
WebSysDescription(SR.WizardStep_Title)
]
public virtual string Title {
get {
string s = (string)ViewState["Title"];
return((s == null) ? String.Empty : s);
}
set {
if (Title != value) {
ViewState["Title"] = value;
if (Owner != null) {
Owner.OnWizardStepsChanged();
}
}
}
}
internal string TitleInternal {
get {
return (string)ViewState["Title"];
}
}
[
Browsable(false),
EditorBrowsable(EditorBrowsableState.Advanced),
WebCategory("Appearance"),
]
public Wizard Wizard {
get {
return Owner;
}
}
// VSWhidbey 397000, need to notify the Owner of type change so
// the sidebar can be re-databound correctly.
protected override void LoadViewState(object savedState) {
if (savedState != null) {
base.LoadViewState(savedState);
if (Owner != null &&
(ViewState["Title"] != null || ViewState["StepType"] != null)) {
Owner.OnWizardStepsChanged();
}
}
}
protected internal override void OnLoad(EventArgs e) {
base.OnLoad(e);
if (Owner == null && !DesignMode) {
throw new InvalidOperationException(SR.GetString(SR.WizardStep_WrongContainment));
}
}
protected internal override void RenderChildren(HtmlTextWriter writer) {
if (!Owner.ShouldRenderChildControl) {
return;
}
base.RenderChildren(writer);
}
}
}
|