Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / WebControls / DropDownList.cs / 1305376 / DropDownList.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.WebControls { using System; using System.Collections; using System.ComponentModel; using System.Collections.Specialized; using System.Drawing; using System.Web; using System.Web.UI; using System.Web.UI.WebControls.Adapters; ////// [ SupportsEventValidation, ValidationProperty("SelectedItem") ] public class DropDownList : ListControl, IPostBackDataHandler { ///Creates a control that allows the user to select a single item from a /// drop-down list. ////// public DropDownList() { } ///Initializes a new instance of the ///class. /// [ Browsable(false) ] public override Color BorderColor { get { return base.BorderColor; } set { base.BorderColor = value; } } ///[To be supplied.] ////// [ Browsable(false) ] public override BorderStyle BorderStyle { get { return base.BorderStyle; } set { base.BorderStyle = value; } } ///[To be supplied.] ////// [ Browsable(false) ] public override Unit BorderWidth { get { return base.BorderWidth; } set { base.BorderWidth = value; } } public override bool SupportsDisabledAttribute { get { return true; } } ///[To be supplied.] ////// [ WebCategory("Behavior"), DefaultValue(0), WebSysDescription(SR.WebControl_SelectedIndex), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden) ] public override int SelectedIndex { get { int selectedIndex = base.SelectedIndex; if (selectedIndex < 0 && Items.Count > 0) { Items[0].Selected = true; selectedIndex = 0; } return selectedIndex; } set { base.SelectedIndex = value; } } internal override ArrayList SelectedIndicesInternal { get { int sideEffect = SelectedIndex; return base.SelectedIndicesInternal; } } protected override void AddAttributesToRender(HtmlTextWriter writer) { string uniqueID = UniqueID; if (uniqueID != null) { writer.AddAttribute(HtmlTextWriterAttribute.Name, uniqueID); } base.AddAttributesToRender(writer); } protected override ControlCollection CreateControlCollection() { return new EmptyControlCollection(this); } ///Gets or sets the index of the item selected by the user /// from the ////// control. /// /// bool IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) { return LoadPostData(postDataKey, postCollection); } ///Process posted data for the ///control. /// /// protected virtual bool LoadPostData(String postDataKey, NameValueCollection postCollection) { // When a DropDownList is disabled, then there is no postback data for it. // Since DropDownList doesn't call RegisterRequiresPostBack, this method will // never be called, so we don't need to worry about ignoring empty postback data. string [] selectedItems = postCollection.GetValues(postDataKey); EnsureDataBound(); if (selectedItems != null) { ValidateEvent(postDataKey, selectedItems[0]); int n = Items.FindByValueInternal(selectedItems[0], false); if (SelectedIndex != n) { SetPostDataSelection(n); return true; } } return false; } ///Process posted data for the ///control. /// /// void IPostBackDataHandler.RaisePostDataChangedEvent() { RaisePostDataChangedEvent(); } ///Raises events for the ///control on post back. /// /// protected virtual void RaisePostDataChangedEvent() { if (AutoPostBack && !Page.IsPostBackEventControlRegistered) { // VSWhidbey 204824 Page.AutoPostBackControl = this; if (CausesValidation) { Page.Validate(ValidationGroup); } } OnSelectedIndexChanged(EventArgs.Empty); } protected internal override void VerifyMultiSelect() { throw new HttpException(SR.GetString(SR.Cant_Multiselect, "DropDownList")); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //Raises events for the ///control on post back. // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.WebControls { using System; using System.Collections; using System.ComponentModel; using System.Collections.Specialized; using System.Drawing; using System.Web; using System.Web.UI; using System.Web.UI.WebControls.Adapters; ////// [ SupportsEventValidation, ValidationProperty("SelectedItem") ] public class DropDownList : ListControl, IPostBackDataHandler { ///Creates a control that allows the user to select a single item from a /// drop-down list. ////// public DropDownList() { } ///Initializes a new instance of the ///class. /// [ Browsable(false) ] public override Color BorderColor { get { return base.BorderColor; } set { base.BorderColor = value; } } ///[To be supplied.] ////// [ Browsable(false) ] public override BorderStyle BorderStyle { get { return base.BorderStyle; } set { base.BorderStyle = value; } } ///[To be supplied.] ////// [ Browsable(false) ] public override Unit BorderWidth { get { return base.BorderWidth; } set { base.BorderWidth = value; } } public override bool SupportsDisabledAttribute { get { return true; } } ///[To be supplied.] ////// [ WebCategory("Behavior"), DefaultValue(0), WebSysDescription(SR.WebControl_SelectedIndex), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden) ] public override int SelectedIndex { get { int selectedIndex = base.SelectedIndex; if (selectedIndex < 0 && Items.Count > 0) { Items[0].Selected = true; selectedIndex = 0; } return selectedIndex; } set { base.SelectedIndex = value; } } internal override ArrayList SelectedIndicesInternal { get { int sideEffect = SelectedIndex; return base.SelectedIndicesInternal; } } protected override void AddAttributesToRender(HtmlTextWriter writer) { string uniqueID = UniqueID; if (uniqueID != null) { writer.AddAttribute(HtmlTextWriterAttribute.Name, uniqueID); } base.AddAttributesToRender(writer); } protected override ControlCollection CreateControlCollection() { return new EmptyControlCollection(this); } ///Gets or sets the index of the item selected by the user /// from the ////// control. /// /// bool IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) { return LoadPostData(postDataKey, postCollection); } ///Process posted data for the ///control. /// /// protected virtual bool LoadPostData(String postDataKey, NameValueCollection postCollection) { // When a DropDownList is disabled, then there is no postback data for it. // Since DropDownList doesn't call RegisterRequiresPostBack, this method will // never be called, so we don't need to worry about ignoring empty postback data. string [] selectedItems = postCollection.GetValues(postDataKey); EnsureDataBound(); if (selectedItems != null) { ValidateEvent(postDataKey, selectedItems[0]); int n = Items.FindByValueInternal(selectedItems[0], false); if (SelectedIndex != n) { SetPostDataSelection(n); return true; } } return false; } ///Process posted data for the ///control. /// /// void IPostBackDataHandler.RaisePostDataChangedEvent() { RaisePostDataChangedEvent(); } ///Raises events for the ///control on post back. /// /// protected virtual void RaisePostDataChangedEvent() { if (AutoPostBack && !Page.IsPostBackEventControlRegistered) { // VSWhidbey 204824 Page.AutoPostBackControl = this; if (CausesValidation) { Page.Validate(ValidationGroup); } } OnSelectedIndexChanged(EventArgs.Empty); } protected internal override void VerifyMultiSelect() { throw new HttpException(SR.GetString(SR.Cant_Multiselect, "DropDownList")); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.Raises events for the ///control on post back.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SqlStream.cs
- GeneralTransform3DTo2DTo3D.cs
- RowVisual.cs
- ResourceProviderFactory.cs
- FixedSOMLineRanges.cs
- RegistrationServices.cs
- BulletedList.cs
- TextDocumentView.cs
- NameValuePermission.cs
- DBPropSet.cs
- SecurityTokenReferenceStyle.cs
- SqlConnectionStringBuilder.cs
- Timer.cs
- ParserContext.cs
- CommandEventArgs.cs
- TabControl.cs
- PopOutPanel.cs
- StrokeFIndices.cs
- AttributeProviderAttribute.cs
- DataListCommandEventArgs.cs
- XpsS0ValidatingLoader.cs
- CopyAttributesAction.cs
- RegionInfo.cs
- AnimatedTypeHelpers.cs
- NameSpaceEvent.cs
- DivideByZeroException.cs
- CTreeGenerator.cs
- FormViewCommandEventArgs.cs
- StylusButton.cs
- DotExpr.cs
- PolygonHotSpot.cs
- DetailsViewPagerRow.cs
- TraceUtility.cs
- BooleanFunctions.cs
- WebPartDisplayModeCollection.cs
- ServiceRouteHandler.cs
- KeyInterop.cs
- InputScopeConverter.cs
- AssociatedControlConverter.cs
- SerialStream.cs
- SizeAnimationBase.cs
- Type.cs
- HttpPostLocalhostServerProtocol.cs
- CustomErrorCollection.cs
- InkCanvasSelectionAdorner.cs
- IListConverters.cs
- HtmlTableRow.cs
- PerformanceCounterNameAttribute.cs
- NativeMethodsOther.cs
- InfoCardRSAPKCS1KeyExchangeDeformatter.cs
- StringStorage.cs
- OrthographicCamera.cs
- DataRelationCollection.cs
- Matrix3DValueSerializer.cs
- ScrollEvent.cs
- CodeGenerator.cs
- ButtonChrome.cs
- OdbcConnection.cs
- HitTestParameters.cs
- ComponentChangedEvent.cs
- WebPartConnectionsConnectVerb.cs
- OpenTypeLayoutCache.cs
- InputQueue.cs
- LambdaCompiler.Lambda.cs
- HwndProxyElementProvider.cs
- PropertyInfoSet.cs
- FileDetails.cs
- IApplicationTrustManager.cs
- VBIdentifierName.cs
- TableRow.cs
- EmbeddedMailObjectsCollection.cs
- StringUtil.cs
- ParallelTimeline.cs
- Cell.cs
- DataGridViewBindingCompleteEventArgs.cs
- ListViewAutomationPeer.cs
- VScrollBar.cs
- WpfKnownMember.cs
- TypeSource.cs
- LastQueryOperator.cs
- DoubleAnimationBase.cs
- CellTreeNodeVisitors.cs
- ComponentCollection.cs
- EllipticalNodeOperations.cs
- XmlDomTextWriter.cs
- ListBoxItem.cs
- MaterialGroup.cs
- COAUTHINFO.cs
- smtppermission.cs
- ElapsedEventArgs.cs
- MessageQueuePermissionEntry.cs
- WindowHideOrCloseTracker.cs
- SettingsPropertyCollection.cs
- IISMapPath.cs
- CFStream.cs
- InheritedPropertyChangedEventArgs.cs
- TrackPointCollection.cs
- HashStream.cs
- MultipleViewPatternIdentifiers.cs
- ObjectStorage.cs