Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / WebControls / LoginName.cs / 1305376 / LoginName.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.WebControls { using System.ComponentModel; using System.Globalization; using System.Web; using System.Web.UI; using System.Web.Util; ////// Renders a Label containing the name of the current user, as defined by the FormatString property. /// Renders nothing if the current user is anonymous. /// [ Bindable(false), Designer("System.Web.UI.Design.WebControls.LoginNameDesigner," + AssemblyRef.SystemDesign), DefaultProperty("FormatString") ] public class LoginName : WebControl { private const string _defaultFormatString = "{0}"; ////// The format specification. {0} is replaced with the user name of the logged in user. /// [ WebCategory("Appearance"), DefaultValue(_defaultFormatString), Localizable(true), WebSysDescription(SR.LoginName_FormatString) ] public virtual string FormatString { get { object obj = ViewState["FormatString"]; return (obj == null) ? _defaultFormatString : (string) obj; } set { ViewState["FormatString"] = value; } } public override bool SupportsDisabledAttribute { get { return RenderingCompatibility < VersionUtil.Framework40; } } internal string UserName { get { if (DesignMode) { return SR.GetString(SR.LoginName_DesignModeUserName); } else { return LoginUtil.GetUserName(this); } } } protected internal override void Render(HtmlTextWriter writer) { if (!String.IsNullOrEmpty(UserName)) { base.Render(writer); } } public override void RenderBeginTag(HtmlTextWriter writer) { // Needed for adapter case to prevent empty span tags if (!String.IsNullOrEmpty(UserName)) { base.RenderBeginTag(writer); } } public override void RenderEndTag(HtmlTextWriter writer) { // Needed for adapter case to prevent empty span tags if (!String.IsNullOrEmpty(UserName)) { base.RenderEndTag(writer); } } ////// Styles would be rendered by the WebControl base class. /// protected internal override void RenderContents(HtmlTextWriter writer) { string userName = UserName; if (!String.IsNullOrEmpty(userName)) { // VSWhidbey 304890 HTMLEncode the username userName = HttpUtility.HtmlEncode(userName); string formatString = FormatString; if (formatString.Length == 0) { writer.Write(userName); } else { try { writer.Write(String.Format(CultureInfo.CurrentCulture, formatString, userName)); } catch (FormatException e) { throw new FormatException(SR.GetString(SR.LoginName_InvalidFormatString), e); } } } } } } // 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
- AssemblySettingAttributes.cs
- PersistenceException.cs
- EnumMember.cs
- DataTemplateKey.cs
- Utils.cs
- SqlConnectionPoolGroupProviderInfo.cs
- BitmapEffectGroup.cs
- CapiNative.cs
- TwoPhaseCommit.cs
- SqlConnectionFactory.cs
- NullableConverter.cs
- BufferedWebEventProvider.cs
- PeerContact.cs
- LinqDataSourceContextEventArgs.cs
- TypeConverterHelper.cs
- CompensableActivity.cs
- OrderedDictionaryStateHelper.cs
- ResourceCollectionInfo.cs
- FlowDocumentPage.cs
- TypeConverterHelper.cs
- DashStyle.cs
- FrameDimension.cs
- XmlArrayAttribute.cs
- SmtpAuthenticationManager.cs
- ModuleElement.cs
- RtfControls.cs
- RotationValidation.cs
- TraceUtils.cs
- PathSegmentCollection.cs
- FileDialogCustomPlacesCollection.cs
- HtmlInputText.cs
- AppDomainUnloadedException.cs
- SerializableAttribute.cs
- wpf-etw.cs
- TCPClient.cs
- CharacterShapingProperties.cs
- DiscoveryClientOutputChannel.cs
- InheritanceRules.cs
- TextPointerBase.cs
- PageThemeParser.cs
- HtmlControl.cs
- NotSupportedException.cs
- EpmCustomContentWriterNodeData.cs
- Win32MouseDevice.cs
- ContextInformation.cs
- ChannelProtectionRequirements.cs
- DataGridViewElement.cs
- ForeignKeyConstraint.cs
- EventLogEntryCollection.cs
- SQLMoney.cs
- LockingPersistenceProvider.cs
- configsystem.cs
- HtmlTableRowCollection.cs
- Int32RectConverter.cs
- ManagementObject.cs
- _NetworkingPerfCounters.cs
- Publisher.cs
- SelectorItemAutomationPeer.cs
- EnumerableRowCollectionExtensions.cs
- XPathMessageFilterElementCollection.cs
- MeshGeometry3D.cs
- DefaultPropertyAttribute.cs
- ToolStripItemClickedEventArgs.cs
- TrackBar.cs
- DelegatingTypeDescriptionProvider.cs
- WebServiceParameterData.cs
- AxisAngleRotation3D.cs
- ProcessHostConfigUtils.cs
- CommandConverter.cs
- ResourceSetExpression.cs
- Listbox.cs
- PinnedBufferMemoryStream.cs
- QueryableDataSourceEditData.cs
- EarlyBoundInfo.cs
- cookieexception.cs
- Material.cs
- Currency.cs
- ParameterReplacerVisitor.cs
- WindowHideOrCloseTracker.cs
- SID.cs
- SqlException.cs
- TextContainerHelper.cs
- BadImageFormatException.cs
- OdbcConnectionStringbuilder.cs
- InvokeMethodActivityDesigner.cs
- TaiwanLunisolarCalendar.cs
- DataAccessor.cs
- OdbcStatementHandle.cs
- Region.cs
- PngBitmapEncoder.cs
- WmiEventSink.cs
- _CookieModule.cs
- SamlAuthorizationDecisionClaimResource.cs
- ColorAnimation.cs
- MatrixTransform3D.cs
- TypeConverterMarkupExtension.cs
- DataGrid.cs
- XmlParser.cs
- TableParaClient.cs
- HebrewCalendar.cs