Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / xsp / System / Web / UI / WebControls / Panel.cs / 1 / Panel.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.WebControls { using System; using System.Web; using System.Web.UI; using System.Collections; using System.ComponentModel; using System.Drawing.Design; using System.Globalization; using System.Security.Permissions; ////// [ Designer("System.Web.UI.Design.WebControls.PanelContainerDesigner, " + AssemblyRef.SystemDesign), ParseChildren(false), PersistChildren(true), ] [AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] public class Panel : WebControl #if ORCAS , IPaginationInfo, IPaginationContainer #endif { #if ORCAS private int _maximumWeight; #endif private string _defaultButton; private bool _renderedFieldSet = false; ///Constructs a panel for specifies layout regions /// on a page and defines its properties. ////// Initializes a new instance of the public Panel() : base(HtmlTextWriterTag.Div) { #if ORCAS _maximumWeight = -1; #endif } #if ORCAS ///class. /// /// [ DefaultValue(true), Themeable(false), WebCategory("Behavior"), WebSysDescription(SR.Panel_AllowPaginate) ] public virtual bool AllowPaginate { get { object u = ViewState["AllowPaginate"]; return (u == null) ? true : (bool)u; } set { ViewState["AllowPaginate"] = value; } } #endif ///[To be supplied.] ////// [ WebCategory("Appearance"), DefaultValue(""), Editor("System.Web.UI.Design.ImageUrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)), UrlProperty(), WebSysDescription(SR.Panel_BackImageUrl) ] public virtual string BackImageUrl { get { if (ControlStyleCreated == false) { return String.Empty; } PanelStyle panelStyle = ControlStyle as PanelStyle; if (panelStyle != null) { return panelStyle.BackImageUrl; } string s = (string)ViewState["BackImageUrl"]; return((s == null) ? String.Empty : s); } set { PanelStyle panelStyle = ControlStyle as PanelStyle; if (panelStyle != null) { panelStyle.BackImageUrl = value; } else { ViewState["BackImageUrl"] = value; } } } ///Gets or sets the URL of the background image for the panel control. ////// Gets or sets default button for the panel /// [ DefaultValue(""), Themeable(false), WebCategory("Behavior"), WebSysDescription(SR.Panel_DefaultButton) ] public virtual string DefaultButton { get { if (_defaultButton == null) { return String.Empty; } return _defaultButton; } set { _defaultButton = value; } } ////// [ DefaultValue(ContentDirection.NotSet), WebCategory("Layout"), WebSysDescription(SR.Panel_Direction) ] public virtual ContentDirection Direction { get { if (ControlStyleCreated == false) { return ContentDirection.NotSet; } PanelStyle panelStyle = ControlStyle as PanelStyle; if (panelStyle != null) { return panelStyle.Direction; } object direction = ViewState["Direction"]; return direction == null ? ContentDirection.NotSet : (ContentDirection) direction; } set { PanelStyle panelStyle = ControlStyle as PanelStyle; if (panelStyle != null) { panelStyle.Direction = value; } else { ViewState["Direction"] = value; } } } [ Localizable(true), DefaultValue(""), WebCategory("Appearance"), WebSysDescription(SR.Panel_GroupingText) ] public virtual string GroupingText { get { string s = (string)ViewState["GroupingText"]; return (s != null) ? s : String.Empty; } set { ViewState["GroupingText"] = value; } } ///Gets or sets the direction of text in the panel ////// [ WebCategory("Layout"), DefaultValue(HorizontalAlign.NotSet), WebSysDescription(SR.Panel_HorizontalAlign) ] public virtual HorizontalAlign HorizontalAlign { get { if (ControlStyleCreated == false) { return HorizontalAlign.NotSet; } PanelStyle panelStyle = ControlStyle as PanelStyle; if (panelStyle != null) { return panelStyle.HorizontalAlign; } object o = ViewState["HorizontalAlign"]; return ((o == null) ? HorizontalAlign.NotSet : (HorizontalAlign)o); } set { PanelStyle panelStyle = ControlStyle as PanelStyle; if (panelStyle != null) { panelStyle.HorizontalAlign = value; } else { if (value < HorizontalAlign.NotSet || value > HorizontalAlign.Justify) { throw new ArgumentOutOfRangeException("value"); } ViewState["HorizontalAlign"] = value; } } } ///Gets or sets the horizontal alignment of the contents within the panel. ////// [ DefaultValue(ScrollBars.None), WebCategory("Layout"), WebSysDescription(SR.Panel_ScrollBars) ] public virtual ScrollBars ScrollBars { get { if (ControlStyleCreated == false) { return ScrollBars.None; } PanelStyle panelStyle = ControlStyle as PanelStyle; if (panelStyle != null) { return panelStyle.ScrollBars; } object scroll = ViewState["ScrollBars"]; return ((scroll == null) ? ScrollBars.None : (ScrollBars)scroll); } set { PanelStyle panelStyle = ControlStyle as PanelStyle; if (panelStyle != null) { panelStyle.ScrollBars = value; } else { ViewState["ScrollBars"] = value; } } } ///Gets or sets the scrollbar behavior of the panel. ////// [ WebCategory("Layout"), DefaultValue(true), WebSysDescription(SR.Panel_Wrap) ] public virtual bool Wrap { get { if (ControlStyleCreated == false) { return true; } PanelStyle panelStyle = ControlStyle as PanelStyle; if (panelStyle != null) { return panelStyle.Wrap; } object b = ViewState["Wrap"]; return ((b == null) ? true : (bool)b); } set { PanelStyle panelStyle = ControlStyle as PanelStyle; if (panelStyle != null) { panelStyle.Wrap = value; } else { ViewState["Wrap"] = value; } } } ///Gets or sets a value /// indicating whether the content wraps within the panel. ////// /// Add background-image to list of style attributes to render. /// Add align and nowrap to list of attributes to render. /// protected override void AddAttributesToRender(HtmlTextWriter writer) { base.AddAttributesToRender(writer); string s = BackImageUrl; // Whidbey 12856 if (s.Trim().Length > 0) { writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundImage, "url(" + ResolveClientUrl(s) + ")"); } AddScrollingAttribute(ScrollBars, writer); HorizontalAlign hAlign = HorizontalAlign; if (hAlign != HorizontalAlign.NotSet) { TypeConverter hac = TypeDescriptor.GetConverter(typeof(HorizontalAlign)); writer.AddStyleAttribute(HtmlTextWriterStyle.TextAlign, hac.ConvertToInvariantString(hAlign).ToLowerInvariant()); } if (!Wrap) { if (EnableLegacyRendering) { writer.AddAttribute(HtmlTextWriterAttribute.Nowrap, "nowrap", false); } else { writer.AddStyleAttribute(HtmlTextWriterStyle.WhiteSpace, "nowrap"); } } if (Direction == ContentDirection.LeftToRight) { writer.AddAttribute(HtmlTextWriterAttribute.Dir, "ltr"); } else if (Direction == ContentDirection.RightToLeft) { writer.AddAttribute(HtmlTextWriterAttribute.Dir, "rtl"); } if (!DesignMode && (Page != null) && (Page.RequestInternal != null) && (Page.Request.Browser.EcmaScriptVersion.Major > 0) && (Page.Request.Browser.W3CDomVersion.Major > 0)) { if (DefaultButton.Length > 0) { Control c = FindControl(DefaultButton); if (c is IButtonControl) { Page.ClientScript.RegisterDefaultButtonScript(c, writer, true /* UseAddAttribute */); } else { throw new InvalidOperationException(SR.GetString(SR.HtmlForm_OnlyIButtonControlCanBeDefaultButton, ID)); } } } } ////// [To be supplied.] /// private void AddScrollingAttribute(ScrollBars scrollBars, HtmlTextWriter writer) { switch (scrollBars) { case ScrollBars.Horizontal: writer.AddStyleAttribute(HtmlTextWriterStyle.OverflowX, "scroll"); break; case ScrollBars.Vertical: writer.AddStyleAttribute(HtmlTextWriterStyle.OverflowY, "scroll"); break; case ScrollBars.Both: writer.AddStyleAttribute(HtmlTextWriterStyle.Overflow, "scroll"); break; case ScrollBars.Auto: writer.AddStyleAttribute(HtmlTextWriterStyle.Overflow, "auto"); break; default: break; } } ////// /// protected override Style CreateControlStyle() { return new PanelStyle(ViewState); } ///A protected method. Creates a panel control style. ///public override void RenderBeginTag(HtmlTextWriter writer) { AddAttributesToRender(writer); HtmlTextWriterTag tagKey = TagKey; if (tagKey != HtmlTextWriterTag.Unknown) { writer.RenderBeginTag(tagKey); } else { writer.RenderBeginTag(TagName); } string s = GroupingText; bool useGrouping = (s.Length != 0) && !(writer is Html32TextWriter); if (useGrouping) { writer.RenderBeginTag(HtmlTextWriterTag.Fieldset); _renderedFieldSet = true; writer.RenderBeginTag(HtmlTextWriterTag.Legend); writer.Write(s); writer.RenderEndTag(); } } public override void RenderEndTag(HtmlTextWriter writer) { if (_renderedFieldSet) { writer.RenderEndTag(); } base.RenderEndTag(writer); } #if ORCAS /// int IPaginationContainer.MaximumWeight { get { return MaximumWeight; } } /// protected virtual int MaximumWeight { get { if (_maximumWeight != -1) { return _maximumWeight; } if(Context != null) { _maximumWeight = Int32.Parse(Context.Request.Browser["optimumPageWeight"], CultureInfo.InvariantCulture); return _maximumWeight; // } else { return -1; } } } /// bool IPaginationInfo.PaginateChildren { get { return PaginateChildren; } } /// protected virtual bool PaginateChildren { get { return AllowPaginate; } } /// int IPaginationInfo.Weight { get { return Weight; } } protected virtual int Weight { get { return 0; } } #endif } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.WebControls { using System; using System.Web; using System.Web.UI; using System.Collections; using System.ComponentModel; using System.Drawing.Design; using System.Globalization; using System.Security.Permissions; ////// [ Designer("System.Web.UI.Design.WebControls.PanelContainerDesigner, " + AssemblyRef.SystemDesign), ParseChildren(false), PersistChildren(true), ] [AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] public class Panel : WebControl #if ORCAS , IPaginationInfo, IPaginationContainer #endif { #if ORCAS private int _maximumWeight; #endif private string _defaultButton; private bool _renderedFieldSet = false; ///Constructs a panel for specifies layout regions /// on a page and defines its properties. ////// Initializes a new instance of the public Panel() : base(HtmlTextWriterTag.Div) { #if ORCAS _maximumWeight = -1; #endif } #if ORCAS ///class. /// /// [ DefaultValue(true), Themeable(false), WebCategory("Behavior"), WebSysDescription(SR.Panel_AllowPaginate) ] public virtual bool AllowPaginate { get { object u = ViewState["AllowPaginate"]; return (u == null) ? true : (bool)u; } set { ViewState["AllowPaginate"] = value; } } #endif ///[To be supplied.] ////// [ WebCategory("Appearance"), DefaultValue(""), Editor("System.Web.UI.Design.ImageUrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)), UrlProperty(), WebSysDescription(SR.Panel_BackImageUrl) ] public virtual string BackImageUrl { get { if (ControlStyleCreated == false) { return String.Empty; } PanelStyle panelStyle = ControlStyle as PanelStyle; if (panelStyle != null) { return panelStyle.BackImageUrl; } string s = (string)ViewState["BackImageUrl"]; return((s == null) ? String.Empty : s); } set { PanelStyle panelStyle = ControlStyle as PanelStyle; if (panelStyle != null) { panelStyle.BackImageUrl = value; } else { ViewState["BackImageUrl"] = value; } } } ///Gets or sets the URL of the background image for the panel control. ////// Gets or sets default button for the panel /// [ DefaultValue(""), Themeable(false), WebCategory("Behavior"), WebSysDescription(SR.Panel_DefaultButton) ] public virtual string DefaultButton { get { if (_defaultButton == null) { return String.Empty; } return _defaultButton; } set { _defaultButton = value; } } ////// [ DefaultValue(ContentDirection.NotSet), WebCategory("Layout"), WebSysDescription(SR.Panel_Direction) ] public virtual ContentDirection Direction { get { if (ControlStyleCreated == false) { return ContentDirection.NotSet; } PanelStyle panelStyle = ControlStyle as PanelStyle; if (panelStyle != null) { return panelStyle.Direction; } object direction = ViewState["Direction"]; return direction == null ? ContentDirection.NotSet : (ContentDirection) direction; } set { PanelStyle panelStyle = ControlStyle as PanelStyle; if (panelStyle != null) { panelStyle.Direction = value; } else { ViewState["Direction"] = value; } } } [ Localizable(true), DefaultValue(""), WebCategory("Appearance"), WebSysDescription(SR.Panel_GroupingText) ] public virtual string GroupingText { get { string s = (string)ViewState["GroupingText"]; return (s != null) ? s : String.Empty; } set { ViewState["GroupingText"] = value; } } ///Gets or sets the direction of text in the panel ////// [ WebCategory("Layout"), DefaultValue(HorizontalAlign.NotSet), WebSysDescription(SR.Panel_HorizontalAlign) ] public virtual HorizontalAlign HorizontalAlign { get { if (ControlStyleCreated == false) { return HorizontalAlign.NotSet; } PanelStyle panelStyle = ControlStyle as PanelStyle; if (panelStyle != null) { return panelStyle.HorizontalAlign; } object o = ViewState["HorizontalAlign"]; return ((o == null) ? HorizontalAlign.NotSet : (HorizontalAlign)o); } set { PanelStyle panelStyle = ControlStyle as PanelStyle; if (panelStyle != null) { panelStyle.HorizontalAlign = value; } else { if (value < HorizontalAlign.NotSet || value > HorizontalAlign.Justify) { throw new ArgumentOutOfRangeException("value"); } ViewState["HorizontalAlign"] = value; } } } ///Gets or sets the horizontal alignment of the contents within the panel. ////// [ DefaultValue(ScrollBars.None), WebCategory("Layout"), WebSysDescription(SR.Panel_ScrollBars) ] public virtual ScrollBars ScrollBars { get { if (ControlStyleCreated == false) { return ScrollBars.None; } PanelStyle panelStyle = ControlStyle as PanelStyle; if (panelStyle != null) { return panelStyle.ScrollBars; } object scroll = ViewState["ScrollBars"]; return ((scroll == null) ? ScrollBars.None : (ScrollBars)scroll); } set { PanelStyle panelStyle = ControlStyle as PanelStyle; if (panelStyle != null) { panelStyle.ScrollBars = value; } else { ViewState["ScrollBars"] = value; } } } ///Gets or sets the scrollbar behavior of the panel. ////// [ WebCategory("Layout"), DefaultValue(true), WebSysDescription(SR.Panel_Wrap) ] public virtual bool Wrap { get { if (ControlStyleCreated == false) { return true; } PanelStyle panelStyle = ControlStyle as PanelStyle; if (panelStyle != null) { return panelStyle.Wrap; } object b = ViewState["Wrap"]; return ((b == null) ? true : (bool)b); } set { PanelStyle panelStyle = ControlStyle as PanelStyle; if (panelStyle != null) { panelStyle.Wrap = value; } else { ViewState["Wrap"] = value; } } } ///Gets or sets a value /// indicating whether the content wraps within the panel. ////// /// Add background-image to list of style attributes to render. /// Add align and nowrap to list of attributes to render. /// protected override void AddAttributesToRender(HtmlTextWriter writer) { base.AddAttributesToRender(writer); string s = BackImageUrl; // Whidbey 12856 if (s.Trim().Length > 0) { writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundImage, "url(" + ResolveClientUrl(s) + ")"); } AddScrollingAttribute(ScrollBars, writer); HorizontalAlign hAlign = HorizontalAlign; if (hAlign != HorizontalAlign.NotSet) { TypeConverter hac = TypeDescriptor.GetConverter(typeof(HorizontalAlign)); writer.AddStyleAttribute(HtmlTextWriterStyle.TextAlign, hac.ConvertToInvariantString(hAlign).ToLowerInvariant()); } if (!Wrap) { if (EnableLegacyRendering) { writer.AddAttribute(HtmlTextWriterAttribute.Nowrap, "nowrap", false); } else { writer.AddStyleAttribute(HtmlTextWriterStyle.WhiteSpace, "nowrap"); } } if (Direction == ContentDirection.LeftToRight) { writer.AddAttribute(HtmlTextWriterAttribute.Dir, "ltr"); } else if (Direction == ContentDirection.RightToLeft) { writer.AddAttribute(HtmlTextWriterAttribute.Dir, "rtl"); } if (!DesignMode && (Page != null) && (Page.RequestInternal != null) && (Page.Request.Browser.EcmaScriptVersion.Major > 0) && (Page.Request.Browser.W3CDomVersion.Major > 0)) { if (DefaultButton.Length > 0) { Control c = FindControl(DefaultButton); if (c is IButtonControl) { Page.ClientScript.RegisterDefaultButtonScript(c, writer, true /* UseAddAttribute */); } else { throw new InvalidOperationException(SR.GetString(SR.HtmlForm_OnlyIButtonControlCanBeDefaultButton, ID)); } } } } ////// [To be supplied.] /// private void AddScrollingAttribute(ScrollBars scrollBars, HtmlTextWriter writer) { switch (scrollBars) { case ScrollBars.Horizontal: writer.AddStyleAttribute(HtmlTextWriterStyle.OverflowX, "scroll"); break; case ScrollBars.Vertical: writer.AddStyleAttribute(HtmlTextWriterStyle.OverflowY, "scroll"); break; case ScrollBars.Both: writer.AddStyleAttribute(HtmlTextWriterStyle.Overflow, "scroll"); break; case ScrollBars.Auto: writer.AddStyleAttribute(HtmlTextWriterStyle.Overflow, "auto"); break; default: break; } } ////// /// protected override Style CreateControlStyle() { return new PanelStyle(ViewState); } ///A protected method. Creates a panel control style. ///public override void RenderBeginTag(HtmlTextWriter writer) { AddAttributesToRender(writer); HtmlTextWriterTag tagKey = TagKey; if (tagKey != HtmlTextWriterTag.Unknown) { writer.RenderBeginTag(tagKey); } else { writer.RenderBeginTag(TagName); } string s = GroupingText; bool useGrouping = (s.Length != 0) && !(writer is Html32TextWriter); if (useGrouping) { writer.RenderBeginTag(HtmlTextWriterTag.Fieldset); _renderedFieldSet = true; writer.RenderBeginTag(HtmlTextWriterTag.Legend); writer.Write(s); writer.RenderEndTag(); } } public override void RenderEndTag(HtmlTextWriter writer) { if (_renderedFieldSet) { writer.RenderEndTag(); } base.RenderEndTag(writer); } #if ORCAS /// int IPaginationContainer.MaximumWeight { get { return MaximumWeight; } } /// protected virtual int MaximumWeight { get { if (_maximumWeight != -1) { return _maximumWeight; } if(Context != null) { _maximumWeight = Int32.Parse(Context.Request.Browser["optimumPageWeight"], CultureInfo.InvariantCulture); return _maximumWeight; // } else { return -1; } } } /// bool IPaginationInfo.PaginateChildren { get { return PaginateChildren; } } /// protected virtual bool PaginateChildren { get { return AllowPaginate; } } /// int IPaginationInfo.Weight { get { return Weight; } } protected virtual int Weight { get { return 0; } } #endif } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- EntityDataSourceDesigner.cs
- SuspendDesigner.cs
- ISAPIApplicationHost.cs
- IsolatedStoragePermission.cs
- XmlSerializationReader.cs
- SamlSecurityTokenAuthenticator.cs
- TraceContextRecord.cs
- WebServiceClientProxyGenerator.cs
- ToolStripGrip.cs
- FixedHighlight.cs
- HttpClientCertificate.cs
- RichTextBoxAutomationPeer.cs
- storagemappingitemcollection.viewdictionary.cs
- Matrix3DStack.cs
- Visitor.cs
- Authorization.cs
- SQLUtility.cs
- IdentityManager.cs
- ComboBox.cs
- WebPartCollection.cs
- PresentationAppDomainManager.cs
- ChildTable.cs
- HostingEnvironmentWrapper.cs
- Helpers.cs
- FileStream.cs
- Calendar.cs
- DbConnectionStringBuilder.cs
- LoginCancelEventArgs.cs
- SubtreeProcessor.cs
- OutputScope.cs
- SystemDiagnosticsSection.cs
- XmlNodeList.cs
- ToolZone.cs
- _NtlmClient.cs
- MetadataException.cs
- WebRequest.cs
- PolicyValidationException.cs
- PathSegmentCollection.cs
- QueueProcessor.cs
- GorillaCodec.cs
- FontUnitConverter.cs
- PropertyGridCommands.cs
- OpenCollectionAsyncResult.cs
- HtmlInputButton.cs
- IApplicationTrustManager.cs
- RpcResponse.cs
- HttpCapabilitiesSectionHandler.cs
- ArgumentFixer.cs
- TreeNodeStyleCollection.cs
- FieldNameLookup.cs
- RMPublishingDialog.cs
- DateTimeHelper.cs
- EdmToObjectNamespaceMap.cs
- Hex.cs
- CompilationRelaxations.cs
- NamespaceQuery.cs
- DataGridAutoGeneratingColumnEventArgs.cs
- Descriptor.cs
- PropertyEmitterBase.cs
- URLMembershipCondition.cs
- Form.cs
- LocalServiceSecuritySettings.cs
- XmlSchemaImport.cs
- MultiTargetingUtil.cs
- Control.cs
- VersionedStream.cs
- ObjectTypeMapping.cs
- XappLauncher.cs
- PasswordBoxAutomationPeer.cs
- TextDecoration.cs
- DebugHandleTracker.cs
- ProviderConnectionPointCollection.cs
- DbBuffer.cs
- CodeArgumentReferenceExpression.cs
- CurrentTimeZone.cs
- CodeSubDirectory.cs
- MetaTableHelper.cs
- AmbientLight.cs
- Size.cs
- XomlCompilerHelpers.cs
- UnsafePeerToPeerMethods.cs
- IItemContainerGenerator.cs
- XPathBuilder.cs
- ZipPackagePart.cs
- HighlightComponent.cs
- ViewManagerAttribute.cs
- InputProcessorProfiles.cs
- SpanIndex.cs
- XPathQilFactory.cs
- OdbcParameter.cs
- JapaneseLunisolarCalendar.cs
- TextElementCollectionHelper.cs
- ProcessProtocolHandler.cs
- Point4D.cs
- CharEnumerator.cs
- XmlSchemaSimpleTypeRestriction.cs
- SortedDictionary.cs
- DirectoryInfo.cs
- FontCacheLogic.cs
- CompModSwitches.cs