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
- IdnMapping.cs
- WinCategoryAttribute.cs
- Statements.cs
- ContextQuery.cs
- FormViewUpdatedEventArgs.cs
- Localizer.cs
- SqlParameterizer.cs
- XamlInt32CollectionSerializer.cs
- StringBuilder.cs
- GridViewColumnHeaderAutomationPeer.cs
- RepeaterItemEventArgs.cs
- URLAttribute.cs
- DataGridTemplateColumn.cs
- VectorCollectionValueSerializer.cs
- Frame.cs
- DataGridAutoFormat.cs
- TdsParserSafeHandles.cs
- ScriptResourceInfo.cs
- RawStylusActions.cs
- ProfileGroupSettings.cs
- SamlEvidence.cs
- XPathPatternParser.cs
- DbConvert.cs
- ConfigurationValues.cs
- FileDialog_Vista.cs
- DeferredBinaryDeserializerExtension.cs
- SuppressMergeCheckAttribute.cs
- HttpServerVarsCollection.cs
- QuadraticEase.cs
- TableLayoutStyleCollection.cs
- TimelineClockCollection.cs
- SoapSchemaExporter.cs
- ButtonBaseAdapter.cs
- TextSpanModifier.cs
- DocumentsTrace.cs
- ToolboxComponentsCreatingEventArgs.cs
- ProfileManager.cs
- ReadOnlyCollectionBase.cs
- ManualResetEvent.cs
- ExpressionBuilderContext.cs
- RichTextBoxAutomationPeer.cs
- SqlFlattener.cs
- LightweightCodeGenerator.cs
- DropTarget.cs
- WorkflowPrinting.cs
- PenThread.cs
- StoreItemCollection.Loader.cs
- InternalControlCollection.cs
- BitmapFrameEncode.cs
- SystemIPInterfaceProperties.cs
- WebZone.cs
- DateTimeUtil.cs
- CodeGroup.cs
- UIElement3D.cs
- MappingException.cs
- ClientConfigurationSystem.cs
- WrappedIUnknown.cs
- TargetPerspective.cs
- QilReplaceVisitor.cs
- FrameworkContextData.cs
- DefaultBinder.cs
- ApplicationGesture.cs
- arc.cs
- PropertyInfo.cs
- VectorValueSerializer.cs
- XmlILConstructAnalyzer.cs
- ObjectHandle.cs
- UserNamePasswordValidator.cs
- DataGridViewCellCollection.cs
- WindowsFont.cs
- ColumnWidthChangedEvent.cs
- DiagnosticTraceRecords.cs
- TimeSpanMinutesConverter.cs
- PtsHelper.cs
- BamlRecordHelper.cs
- PasswordTextNavigator.cs
- FontWeightConverter.cs
- ListBoxItemWrapperAutomationPeer.cs
- RawStylusSystemGestureInputReport.cs
- LogFlushAsyncResult.cs
- ContextStaticAttribute.cs
- dbdatarecord.cs
- LocalsItemDescription.cs
- bindurihelper.cs
- CustomErrorsSectionWrapper.cs
- WindowsIdentity.cs
- _HTTPDateParse.cs
- DragDrop.cs
- EntityContainer.cs
- XmlSchemaSequence.cs
- path.cs
- TabletDevice.cs
- SrgsSubset.cs
- ApplicationDirectory.cs
- FeatureSupport.cs
- dataobject.cs
- Rfc2898DeriveBytes.cs
- SqlMethodAttribute.cs
- XmlAttributes.cs
- ColorConverter.cs