Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / xsp / System / Web / UI / WebControls / Literal.cs / 1 / Literal.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls {
using System;
using System.ComponentModel;
using System.Globalization;
using System.Web;
using System.Web.UI;
using System.Security.Permissions;
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public class LiteralControlBuilder : ControlBuilder {
public override bool AllowWhitespaceLiterals() {
return false;
}
public override void AppendLiteralString(string s) {
// If it's just a white space string, delegate to the base
if (Util.IsWhiteSpaceString(s)) {
base.AppendLiteralString(s);
return;
}
// Treat the inner text as if it had been set on the 'Text' attribute
PreprocessAttribute(String.Empty /*filter*/, "text", s, false /*mainDirectiveMode*/);
}
public override void AppendSubBuilder(ControlBuilder subBuilder) {
throw new HttpException(SR.GetString(SR.Control_does_not_allow_children,
ControlType.ToString()));
}
}
// The reason we define this empty override in the WebControls namespace is
// to expose it as a control that can be used on a page (ASURT 54683)
// E.g.
[
DataBindingHandler("System.Web.UI.Design.TextDataBindingHandler, " + AssemblyRef.SystemDesign),
DefaultProperty("Text"),
Designer("System.Web.UI.Design.WebControls.LiteralDesigner, " + AssemblyRef.SystemDesign),
ControlBuilderAttribute(typeof(LiteralControlBuilder)),
]
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public class Literal : Control, ITextControl {
///
/// [To be supplied.]
///
[
DefaultValue(LiteralMode.Transform),
WebCategory("Behavior"),
WebSysDescription(SR.Literal_Mode)
]
public LiteralMode Mode {
get {
object mode = ViewState["Mode"];
return mode == null ? LiteralMode.Transform : (LiteralMode)mode;
}
set {
if ((value < LiteralMode.Transform) || (value > LiteralMode.Encode)) {
throw new ArgumentOutOfRangeException("value");
}
ViewState["Mode"] = value;
}
}
///
/// [To be supplied.]
///
[
Localizable(true),
Bindable(true),
WebCategory("Appearance"),
DefaultValue(""),
WebSysDescription(SR.Literal_Text),
]
public string Text {
get {
string s = (string)ViewState["Text"];
return (s != null) ? s : String.Empty;
}
set {
ViewState["Text"] = value;
}
}
///
///
/// [To be supplied.]
///
protected override void AddParsedSubObject(object obj) {
if (obj is LiteralControl) {
Text = ((LiteralControl)obj).Text;
}
else {
throw new HttpException(SR.GetString(SR.Cannot_Have_Children_Of_Type, "Literal", obj.GetType().Name.ToString(CultureInfo.InvariantCulture)));
}
}
///
/// [To be supplied.]
///
protected override ControlCollection CreateControlCollection() {
return new EmptyControlCollection(this);
}
///
///
[
EditorBrowsable(EditorBrowsableState.Never),
]
public override void Focus() {
throw new NotSupportedException(SR.GetString(SR.NoFocusSupport, this.GetType().Name));
}
///
/// [To be supplied.]
///
protected internal override void Render(HtmlTextWriter writer) {
string text = Text;
if (text.Length != 0) {
if (Mode != LiteralMode.Encode) {
writer.Write(text);
return;
}
HttpUtility.HtmlEncode(text, writer);
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls {
using System;
using System.ComponentModel;
using System.Globalization;
using System.Web;
using System.Web.UI;
using System.Security.Permissions;
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public class LiteralControlBuilder : ControlBuilder {
public override bool AllowWhitespaceLiterals() {
return false;
}
public override void AppendLiteralString(string s) {
// If it's just a white space string, delegate to the base
if (Util.IsWhiteSpaceString(s)) {
base.AppendLiteralString(s);
return;
}
// Treat the inner text as if it had been set on the 'Text' attribute
PreprocessAttribute(String.Empty /*filter*/, "text", s, false /*mainDirectiveMode*/);
}
public override void AppendSubBuilder(ControlBuilder subBuilder) {
throw new HttpException(SR.GetString(SR.Control_does_not_allow_children,
ControlType.ToString()));
}
}
// The reason we define this empty override in the WebControls namespace is
// to expose it as a control that can be used on a page (ASURT 54683)
// E.g.
[
DataBindingHandler("System.Web.UI.Design.TextDataBindingHandler, " + AssemblyRef.SystemDesign),
DefaultProperty("Text"),
Designer("System.Web.UI.Design.WebControls.LiteralDesigner, " + AssemblyRef.SystemDesign),
ControlBuilderAttribute(typeof(LiteralControlBuilder)),
]
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public class Literal : Control, ITextControl {
///
/// [To be supplied.]
///
[
DefaultValue(LiteralMode.Transform),
WebCategory("Behavior"),
WebSysDescription(SR.Literal_Mode)
]
public LiteralMode Mode {
get {
object mode = ViewState["Mode"];
return mode == null ? LiteralMode.Transform : (LiteralMode)mode;
}
set {
if ((value < LiteralMode.Transform) || (value > LiteralMode.Encode)) {
throw new ArgumentOutOfRangeException("value");
}
ViewState["Mode"] = value;
}
}
///
/// [To be supplied.]
///
[
Localizable(true),
Bindable(true),
WebCategory("Appearance"),
DefaultValue(""),
WebSysDescription(SR.Literal_Text),
]
public string Text {
get {
string s = (string)ViewState["Text"];
return (s != null) ? s : String.Empty;
}
set {
ViewState["Text"] = value;
}
}
///
///
/// [To be supplied.]
///
protected override void AddParsedSubObject(object obj) {
if (obj is LiteralControl) {
Text = ((LiteralControl)obj).Text;
}
else {
throw new HttpException(SR.GetString(SR.Cannot_Have_Children_Of_Type, "Literal", obj.GetType().Name.ToString(CultureInfo.InvariantCulture)));
}
}
///
/// [To be supplied.]
///
protected override ControlCollection CreateControlCollection() {
return new EmptyControlCollection(this);
}
///
///
[
EditorBrowsable(EditorBrowsableState.Never),
]
public override void Focus() {
throw new NotSupportedException(SR.GetString(SR.NoFocusSupport, this.GetType().Name));
}
///
/// [To be supplied.]
///
protected internal override void Render(HtmlTextWriter writer) {
string text = Text;
if (text.Length != 0) {
if (Mode != LiteralMode.Encode) {
writer.Write(text);
return;
}
HttpUtility.HtmlEncode(text, writer);
}
}
}
}
// 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
- DPAPIProtectedConfigurationProvider.cs
- WebPartCollection.cs
- CursorConverter.cs
- ProfileManager.cs
- CollectionViewSource.cs
- CRYPTPROTECT_PROMPTSTRUCT.cs
- NativeMethods.cs
- TransformGroup.cs
- IteratorFilter.cs
- AnimatedTypeHelpers.cs
- XmlWellformedWriterHelpers.cs
- CollectionDataContractAttribute.cs
- HttpHandlersSection.cs
- InternalConfigRoot.cs
- ControlBuilder.cs
- XamlWrappingReader.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- WorkflowInstanceProxy.cs
- MetadataWorkspace.cs
- unsafenativemethodstextservices.cs
- SQLInt64Storage.cs
- EventDescriptor.cs
- HandleRef.cs
- ActivityDesigner.cs
- VSWCFServiceContractGenerator.cs
- ControlEvent.cs
- TagPrefixAttribute.cs
- UriTemplateClientFormatter.cs
- TrackBarRenderer.cs
- MultilineStringEditor.cs
- Properties.cs
- PreProcessInputEventArgs.cs
- Metadata.cs
- GridItemCollection.cs
- BaseParser.cs
- SynchronizedDispatch.cs
- XmlSchemaResource.cs
- MatchingStyle.cs
- XmlTextEncoder.cs
- SQLBytes.cs
- SecureUICommand.cs
- SimpleFileLog.cs
- BitmapEffect.cs
- PkcsMisc.cs
- StateWorkerRequest.cs
- StatusBar.cs
- ImmutableDispatchRuntime.cs
- DesignerCatalogPartChrome.cs
- dsa.cs
- FieldTemplateUserControl.cs
- DataGridRow.cs
- Int64Animation.cs
- ControlPaint.cs
- SQLBoolean.cs
- AlphabeticalEnumConverter.cs
- _FixedSizeReader.cs
- InputLangChangeRequestEvent.cs
- PasswordDeriveBytes.cs
- FixedFlowMap.cs
- PolicyLevel.cs
- DataGridViewRowStateChangedEventArgs.cs
- WebBrowser.cs
- DataServiceOperationContext.cs
- CompositionTarget.cs
- StorageEntitySetMapping.cs
- XPathDocumentBuilder.cs
- TimeSpanStorage.cs
- ProvidePropertyAttribute.cs
- ClosableStream.cs
- CodeIdentifiers.cs
- SecurityElement.cs
- SqlDataSourceConfigureFilterForm.cs
- InternalConfigConfigurationFactory.cs
- EntityFrameworkVersions.cs
- MatrixCamera.cs
- AdjustableArrowCap.cs
- Rules.cs
- WindowsTokenRoleProvider.cs
- TypeForwardedFromAttribute.cs
- OpenTypeCommon.cs
- DataServiceQueryProvider.cs
- InvokeGenerator.cs
- OrderPreservingSpoolingTask.cs
- MessagePropertyFilter.cs
- DataSourceHelper.cs
- InheritablePropertyChangeInfo.cs
- DataRowExtensions.cs
- XmlUrlResolver.cs
- Globals.cs
- Tile.cs
- TracedNativeMethods.cs
- ProtectedConfigurationSection.cs
- TypeValidationEventArgs.cs
- EntityDataSourceMemberPath.cs
- CompilationUtil.cs
- ProtocolsConfigurationEntry.cs
- PolyBezierSegment.cs
- SecurityContext.cs
- WebBrowserContainer.cs
- Calendar.cs