Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- UrlAuthFailedErrorFormatter.cs
- ValidationErrorEventArgs.cs
- VarRemapper.cs
- XPathDescendantIterator.cs
- ToolStripOverflow.cs
- GiveFeedbackEventArgs.cs
- SystemSounds.cs
- SafeNativeMethods.cs
- LocalizableResourceBuilder.cs
- WebPartManager.cs
- Transform.cs
- Events.cs
- IBuiltInEvidence.cs
- VideoDrawing.cs
- JsonEncodingStreamWrapper.cs
- SerializationAttributes.cs
- ClientSponsor.cs
- PeerInputChannel.cs
- ResourceManagerWrapper.cs
- InputManager.cs
- ProcessModelSection.cs
- SoapEnumAttribute.cs
- DiscoveryExceptionDictionary.cs
- ApplicationServicesHostFactory.cs
- _Rfc2616CacheValidators.cs
- InstanceCreationEditor.cs
- DocumentViewer.cs
- WmpBitmapEncoder.cs
- XsltConvert.cs
- BitStream.cs
- ToolStripMenuItem.cs
- CodeTypeReferenceCollection.cs
- FileLogRecordEnumerator.cs
- WebPartExportVerb.cs
- ParameterToken.cs
- EventRoute.cs
- WebMethodAttribute.cs
- DataGridViewCellValueEventArgs.cs
- InlineObject.cs
- IdentityHolder.cs
- UnsafeNetInfoNativeMethods.cs
- NodeInfo.cs
- WebCodeGenerator.cs
- CatalogZoneBase.cs
- GridErrorDlg.cs
- LocalizationComments.cs
- Attributes.cs
- ObfuscateAssemblyAttribute.cs
- MailDefinition.cs
- TableParagraph.cs
- Terminate.cs
- TraceSource.cs
- DataSourceCacheDurationConverter.cs
- SoapFormatterSinks.cs
- Perspective.cs
- UTF8Encoding.cs
- ParenthesizePropertyNameAttribute.cs
- SqlClientFactory.cs
- XmlRawWriter.cs
- UriExt.cs
- TextTreeObjectNode.cs
- WindowsFormsHost.cs
- SqlConnection.cs
- MultiViewDesigner.cs
- FileDialog_Vista.cs
- MouseGesture.cs
- MetadataItemSerializer.cs
- FormatException.cs
- OdbcEnvironment.cs
- QueryableDataSourceHelper.cs
- DetailsViewPageEventArgs.cs
- SqlCacheDependency.cs
- RawTextInputReport.cs
- CodeIdentifiers.cs
- WorkflowServiceHostFactory.cs
- TextPatternIdentifiers.cs
- AdPostCacheSubstitution.cs
- SkewTransform.cs
- DesignTimeData.cs
- DragDeltaEventArgs.cs
- XmlCharCheckingWriter.cs
- ResourceExpression.cs
- SqlMethodAttribute.cs
- ReachUIElementCollectionSerializer.cs
- ModuleConfigurationInfo.cs
- HttpValueCollection.cs
- RuntimeHandles.cs
- TreeNodeMouseHoverEvent.cs
- PublisherMembershipCondition.cs
- Evidence.cs
- NonBatchDirectoryCompiler.cs
- AttachInfo.cs
- SafeThreadHandle.cs
- CriticalHandle.cs
- MimeMultiPart.cs
- IdentitySection.cs
- StrongNameUtility.cs
- PhysicalOps.cs
- RuntimeWrappedException.cs
- WebPartMenuStyle.cs