Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Extensions / UI / ControlUtil.cs / 1305376 / ControlUtil.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Text; using System.Web.Resources; using System.Web.UI; namespace System.Web.UI { internal class ControlUtil { internal static Control FindTargetControl(string controlID, Control control, bool searchNamingContainers) { Control foundControl; if (searchNamingContainers) { Control currentContainer; foundControl = null; // DevDiv 73305: Do not assume starting control is not a naming container. if (control is INamingContainer) { currentContainer = control; } else { currentContainer = control.NamingContainer; } do { foundControl = currentContainer.FindControl(controlID); currentContainer = currentContainer.NamingContainer; } while (foundControl == null && currentContainer != null); } else { foundControl = control.FindControl(controlID); } return foundControl; } internal static bool IsBuiltInHiddenField(string hiddenFieldName) { // Returns true is the field name represents a hidden field generated // by ASP.NET's core runtime. This includes fields such as ViewState and // EventValidation, but not ones generated by specific controls such as // TreeView and WebParts. // If the field is less than two chars long it's not built-in. (Perf) if (hiddenFieldName.Length <= 2) { return false; } // If it doesn't start with two underscores, it's not built-in. (Perf) if (hiddenFieldName[0] != '_' || hiddenFieldName[1] != '_') { return false; } // Examine list of built-in ASP.NET fields. The list was created by examining // the ASP.NET source code for hidden field registration and rendering. // We exclude __VIEWSTATEENCRYPTED and __VIEWSTATEFIELDCOUNT from the list // since they're covered by the general __VIEWSTATE part. return hiddenFieldName.StartsWith("__VIEWSTATE", StringComparison.Ordinal) || String.Equals(hiddenFieldName, "__EVENTVALIDATION", StringComparison.Ordinal) || String.Equals(hiddenFieldName, "__LASTFOCUS", StringComparison.Ordinal) || String.Equals(hiddenFieldName, "__SCROLLPOSITIONX", StringComparison.Ordinal) || String.Equals(hiddenFieldName, "__SCROLLPOSITIONY", StringComparison.Ordinal) || String.Equals(hiddenFieldName, "__EVENTTARGET", StringComparison.Ordinal) || String.Equals(hiddenFieldName, "__EVENTARGUMENT", StringComparison.Ordinal) || String.Equals(hiddenFieldName, "__PREVIOUSPAGE", StringComparison.Ordinal); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Text; using System.Web.Resources; using System.Web.UI; namespace System.Web.UI { internal class ControlUtil { internal static Control FindTargetControl(string controlID, Control control, bool searchNamingContainers) { Control foundControl; if (searchNamingContainers) { Control currentContainer; foundControl = null; // DevDiv 73305: Do not assume starting control is not a naming container. if (control is INamingContainer) { currentContainer = control; } else { currentContainer = control.NamingContainer; } do { foundControl = currentContainer.FindControl(controlID); currentContainer = currentContainer.NamingContainer; } while (foundControl == null && currentContainer != null); } else { foundControl = control.FindControl(controlID); } return foundControl; } internal static bool IsBuiltInHiddenField(string hiddenFieldName) { // Returns true is the field name represents a hidden field generated // by ASP.NET's core runtime. This includes fields such as ViewState and // EventValidation, but not ones generated by specific controls such as // TreeView and WebParts. // If the field is less than two chars long it's not built-in. (Perf) if (hiddenFieldName.Length <= 2) { return false; } // If it doesn't start with two underscores, it's not built-in. (Perf) if (hiddenFieldName[0] != '_' || hiddenFieldName[1] != '_') { return false; } // Examine list of built-in ASP.NET fields. The list was created by examining // the ASP.NET source code for hidden field registration and rendering. // We exclude __VIEWSTATEENCRYPTED and __VIEWSTATEFIELDCOUNT from the list // since they're covered by the general __VIEWSTATE part. return hiddenFieldName.StartsWith("__VIEWSTATE", StringComparison.Ordinal) || String.Equals(hiddenFieldName, "__EVENTVALIDATION", StringComparison.Ordinal) || String.Equals(hiddenFieldName, "__LASTFOCUS", StringComparison.Ordinal) || String.Equals(hiddenFieldName, "__SCROLLPOSITIONX", StringComparison.Ordinal) || String.Equals(hiddenFieldName, "__SCROLLPOSITIONY", StringComparison.Ordinal) || String.Equals(hiddenFieldName, "__EVENTTARGET", StringComparison.Ordinal) || String.Equals(hiddenFieldName, "__EVENTARGUMENT", StringComparison.Ordinal) || String.Equals(hiddenFieldName, "__PREVIOUSPAGE", StringComparison.Ordinal); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TextEffect.cs
- InvalidComObjectException.cs
- DependencyPropertyKind.cs
- ToolStripDesigner.cs
- StyleModeStack.cs
- DataGridViewAutoSizeColumnsModeEventArgs.cs
- PackWebRequest.cs
- PageFunction.cs
- PointHitTestResult.cs
- TabControl.cs
- WebPartPersonalization.cs
- ISAPIWorkerRequest.cs
- ManipulationCompletedEventArgs.cs
- SectionUpdates.cs
- ChangeTracker.cs
- EnterpriseServicesHelper.cs
- Transform.cs
- DataGridTableCollection.cs
- Int16Converter.cs
- DataGridViewColumnEventArgs.cs
- ManifestResourceInfo.cs
- MainMenu.cs
- SkipStoryboardToFill.cs
- AvTraceFormat.cs
- MorphHelpers.cs
- TraceLevelStore.cs
- GradientStop.cs
- SHA1Managed.cs
- SkipStoryboardToFill.cs
- InputLanguageSource.cs
- Point3D.cs
- InkCanvasFeedbackAdorner.cs
- LinqDataView.cs
- MessageDecoder.cs
- PartitionerQueryOperator.cs
- SourceFilter.cs
- FontUnit.cs
- PropertyEmitterBase.cs
- TimerElapsedEvenArgs.cs
- ChildDocumentBlock.cs
- CacheVirtualItemsEvent.cs
- X509UI.cs
- HwndProxyElementProvider.cs
- QuestionEventArgs.cs
- UriTemplateTable.cs
- ContentElement.cs
- WebPartManager.cs
- AutomationElementCollection.cs
- RangeValuePattern.cs
- FactoryMaker.cs
- WhereQueryOperator.cs
- WebPartConnectionsCancelEventArgs.cs
- OdbcCommand.cs
- DefaultBinder.cs
- OrderByBuilder.cs
- LeafCellTreeNode.cs
- CompositeKey.cs
- SrgsToken.cs
- CodeChecksumPragma.cs
- XmlSchemaSimpleContentExtension.cs
- DSASignatureDeformatter.cs
- TreePrinter.cs
- PermissionSetEnumerator.cs
- BamlWriter.cs
- DataGridRowAutomationPeer.cs
- MenuItemCollection.cs
- PrefixHandle.cs
- ResumeStoryboard.cs
- ObjectDataSourceStatusEventArgs.cs
- WSSecureConversation.cs
- GraphicsContainer.cs
- PeerInvitationResponse.cs
- ElementsClipboardData.cs
- LicFileLicenseProvider.cs
- WindowInteropHelper.cs
- Util.cs
- WindowProviderWrapper.cs
- TokenBasedSetEnumerator.cs
- JavaScriptObjectDeserializer.cs
- XmlEnumAttribute.cs
- SizeConverter.cs
- Keyboard.cs
- LoginName.cs
- BinaryCommonClasses.cs
- EllipseGeometry.cs
- SafeRightsManagementSessionHandle.cs
- RewritingPass.cs
- ProviderException.cs
- OledbConnectionStringbuilder.cs
- EntityConnectionStringBuilder.cs
- Hex.cs
- PageContentCollection.cs
- ToolStripDropTargetManager.cs
- StringUtil.cs
- ManagementPath.cs
- MailHeaderInfo.cs
- RijndaelCryptoServiceProvider.cs
- sqlpipe.cs
- COM2PictureConverter.cs
- CompilerWrapper.cs