Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / ndp / fx / src / xsp / System / Web / UI / WebControls / DropDownList.cs / 3 / 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;
using System.Security.Permissions;
///
/// Creates a control that allows the user to select a single item from a
/// drop-down list.
///
[
SupportsEventValidation,
ValidationProperty("SelectedItem")
]
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public class DropDownList : ListControl, IPostBackDataHandler {
///
/// Initializes a new instance of the class.
///
public DropDownList() {
}
///
/// [To be supplied.]
///
[
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;
}
}
///
/// Gets or sets the index of the item selected by the user
/// from the
/// control.
///
[
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);
}
///
///
/// Process posted data for 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;
}
///
///
/// Raises events for the control on post back.
///
void IPostBackDataHandler.RaisePostDataChangedEvent() {
RaisePostDataChangedEvent();
}
///
///
/// Raises events for the control on post back.
///
protected virtual void RaisePostDataChangedEvent() {
if (AutoPostBack && !Page.IsPostBackEventControlRegistered) {
//
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.
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
//
// 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;
using System.Security.Permissions;
///
/// Creates a control that allows the user to select a single item from a
/// drop-down list.
///
[
SupportsEventValidation,
ValidationProperty("SelectedItem")
]
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public class DropDownList : ListControl, IPostBackDataHandler {
///
/// Initializes a new instance of the class.
///
public DropDownList() {
}
///
/// [To be supplied.]
///
[
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;
}
}
///
/// Gets or sets the index of the item selected by the user
/// from the
/// control.
///
[
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);
}
///
///
/// Process posted data for 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;
}
///
///
/// Raises events for the control on post back.
///
void IPostBackDataHandler.RaisePostDataChangedEvent() {
RaisePostDataChangedEvent();
}
///
///
/// Raises events for the control on post back.
///
protected virtual void RaisePostDataChangedEvent() {
if (AutoPostBack && !Page.IsPostBackEventControlRegistered) {
//
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.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TraceSection.cs
- Errors.cs
- BasicKeyConstraint.cs
- Typography.cs
- TypeUtils.cs
- WindowsAuthenticationEventArgs.cs
- PathFigureCollectionConverter.cs
- XmlNodeComparer.cs
- CellParagraph.cs
- OdbcRowUpdatingEvent.cs
- Material.cs
- OdbcEnvironment.cs
- RNGCryptoServiceProvider.cs
- DataGridDesigner.cs
- prompt.cs
- RadioButtonFlatAdapter.cs
- WebBrowserNavigatedEventHandler.cs
- AnimatedTypeHelpers.cs
- DashStyle.cs
- FileAuthorizationModule.cs
- SharedRuntimeState.cs
- FusionWrap.cs
- MailDefinitionBodyFileNameEditor.cs
- AnnotationResourceChangedEventArgs.cs
- DefaultWorkflowLoaderService.cs
- CodeTypeMember.cs
- SpeechUI.cs
- LineGeometry.cs
- TdsEnums.cs
- ConfigurationValidatorAttribute.cs
- SqlWriter.cs
- XmlChildNodes.cs
- AsyncResult.cs
- AttachedPropertyDescriptor.cs
- Selection.cs
- Configuration.cs
- ObjectNavigationPropertyMapping.cs
- ListView.cs
- AccessKeyManager.cs
- ThemeDictionaryExtension.cs
- TraceHelpers.cs
- HttpCapabilitiesBase.cs
- SymDocumentType.cs
- DocumentReference.cs
- ContractSearchPattern.cs
- DataKeyArray.cs
- Math.cs
- sqlser.cs
- RelationshipSet.cs
- DeviceContext2.cs
- SymmetricCryptoHandle.cs
- StringExpressionSet.cs
- OutputWindow.cs
- MouseGestureConverter.cs
- DataSourceControlBuilder.cs
- HebrewNumber.cs
- SqlRetyper.cs
- DbUpdateCommandTree.cs
- ToolZone.cs
- TimeoutException.cs
- FlowDocumentScrollViewer.cs
- TypeUnloadedException.cs
- ActiveXSite.cs
- ListSurrogate.cs
- DocumentCollection.cs
- IOException.cs
- ApplicationBuildProvider.cs
- Manipulation.cs
- TagPrefixInfo.cs
- PropertyBuilder.cs
- StreamMarshaler.cs
- InitializerFacet.cs
- TextBox.cs
- CoreChannel.cs
- HitTestResult.cs
- InitializeCorrelation.cs
- TimeoutConverter.cs
- DiscreteKeyFrames.cs
- DesignerForm.cs
- Form.cs
- Encoder.cs
- PageVisual.cs
- ExternalException.cs
- XmlIlGenerator.cs
- XmlDeclaration.cs
- PersonalizationProvider.cs
- ObjectViewEntityCollectionData.cs
- Rect3DConverter.cs
- DashStyle.cs
- ObjectPersistData.cs
- HtmlTable.cs
- BrowserPolicyValidator.cs
- bindurihelper.cs
- DesigntimeLicenseContextSerializer.cs
- HttpCookiesSection.cs
- BaseDataList.cs
- LineServicesRun.cs
- CompilationUnit.cs
- SByte.cs
- InkCanvasFeedbackAdorner.cs