Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -0,0 +1,283 @@
//------------------------------------------------------------------------------
// <copyright file="HtmlAnchor.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
* HtmlAnchor.cs
*
* Copyright (c) 2000 Microsoft Corporation
*/
namespace System.Web.UI.HtmlControls {
using System.ComponentModel;
using System;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.Util;
using System.Security.Permissions;
/// <devdoc>
/// <para>The <see langword='HtmlAnchor'/>
/// class defines the methods, properties, and
/// events for the HtmlAnchor control.
/// This
/// class
/// allows programmatic access to the
/// HTML &lt;a&gt; element on the server.</para>
/// </devdoc>
[
DefaultEvent("ServerClick"),
SupportsEventValidation,
]
public class HtmlAnchor : HtmlContainerControl, IPostBackEventHandler {
private static readonly object EventServerClick = new object();
/*
* Creates an intrinsic Html A control.
*/
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.Web.UI.HtmlControls.HtmlAnchor'/> class.</para>
/// </devdoc>
public HtmlAnchor() : base("a") {
}
[
WebCategory("Behavior"),
DefaultValue(true),
]
public virtual bool CausesValidation {
get {
object b = ViewState["CausesValidation"];
return((b == null) ? true : (bool)b);
}
set {
ViewState["CausesValidation"] = value;
}
}
/*
* Href property.
*/
/// <devdoc>
/// <para>Gets or sets the URL target of the link specified in the
/// <see cref='System.Web.UI.HtmlControls.HtmlAnchor'/>
/// server control.</para>
/// </devdoc>
[
WebCategory("Navigation"),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
UrlProperty()
]
public string HRef {
get {
string s = Attributes["href"];
return((s != null) ? s : String.Empty);
}
set {
Attributes["href"] = MapStringAttributeToString(value);
}
}
/*
* Name of group this radio is in.
*/
/// <devdoc>
/// <para>Gets or sets the bookmark name defined in the <see cref='System.Web.UI.HtmlControls.HtmlAnchor'/>
/// server
/// control.</para>
/// </devdoc>
[
WebCategory("Navigation"),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
public string Name {
get {
string s = Attributes["name"];
return((s != null) ? s : String.Empty);
}
set {
Attributes["name"] = MapStringAttributeToString(value);
}
}
/*
* Target window property.
*/
/// <devdoc>
/// <para>
/// Gets or
/// sets the target window or frame
/// to load linked Web page content into.
/// </para>
/// </devdoc>
[
WebCategory("Navigation"),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
public string Target {
get {
string s = Attributes["target"];
return((s != null) ? s : String.Empty);
}
set {
Attributes["target"] = MapStringAttributeToString(value);
}
}
/*
* Title property.
*/
/// <devdoc>
/// <para> Gets or sets the title that
/// the browser displays when identifying linked content.</para>
/// </devdoc>
[
WebCategory("Appearance"),
Localizable(true),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
public string Title {
get {
string s = Attributes["title"];
return((s != null) ? s : String.Empty);
}
set {
Attributes["title"] = MapStringAttributeToString(value);
}
}
[
WebCategory("Behavior"),
DefaultValue(""),
WebSysDescription(SR.PostBackControl_ValidationGroup)
]
public virtual string ValidationGroup {
get {
string s = (string)ViewState["ValidationGroup"];
return((s == null) ? string.Empty : s);
}
set {
ViewState["ValidationGroup"] = value;
}
}
/// <devdoc>
/// <para>Occurs on the server when a user clicks the <see cref='System.Web.UI.HtmlControls.HtmlAnchor'/> control on the
/// browser.</para>
/// </devdoc>
[
WebCategory("Action"),
WebSysDescription(SR.HtmlControl_OnServerClick)
]
public event EventHandler ServerClick {
add {
Events.AddHandler(EventServerClick, value);
}
remove {
Events.RemoveHandler(EventServerClick, value);
}
}
private PostBackOptions GetPostBackOptions() {
PostBackOptions options = new PostBackOptions(this, string.Empty);
options.RequiresJavaScriptProtocol = true;
if (CausesValidation && Page.GetValidators(ValidationGroup).Count > 0) {
options.PerformValidation = true;
options.ValidationGroup = ValidationGroup;
}
return options;
}
/// <internalonly/>
protected internal override void OnPreRender(EventArgs e) {
base.OnPreRender(e);
if (Page != null && Events[EventServerClick] != null) {
Page.RegisterPostBackScript();
// VSWhidbey 489577
if (CausesValidation && Page.GetValidators(ValidationGroup).Count > 0) {
Page.RegisterWebFormsScript();
}
}
}
/*
* Override to generate postback code for onclick.
*/
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected override void RenderAttributes(HtmlTextWriter writer) {
if (Events[EventServerClick] != null) {
Attributes.Remove("href");
base.RenderAttributes(writer);
PostBackOptions options = GetPostBackOptions();
Debug.Assert(options != null);
string postBackEventReference = Page.ClientScript.GetPostBackEventReference(options, true);
Debug.Assert(!string.IsNullOrEmpty(postBackEventReference));
writer.WriteAttribute("href", postBackEventReference, true);
}
else {
PreProcessRelativeReferenceAttribute(writer, "href");
base.RenderAttributes(writer);
}
}
/*
* Method used to raise the OnServerClick event.
*/
/// <devdoc>
/// <para>Raises the <see langword='ServerClick'/>
/// event.</para>
/// </devdoc>
protected virtual void OnServerClick(EventArgs e) {
EventHandler handler = (EventHandler)Events[EventServerClick];
if (handler != null) handler(this, e);
}
/*
* Method of IPostBackEventHandler interface to raise events on post back.
* Button fires an OnServerClick event.
*/
/// <internalonly/>
/// <devdoc>
/// </devdoc>
void IPostBackEventHandler.RaisePostBackEvent(string eventArgument) {
RaisePostBackEvent(eventArgument);
}
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected virtual void RaisePostBackEvent(string eventArgument) {
ValidateEvent(UniqueID, eventArgument);
if (CausesValidation) {
Page.Validate(ValidationGroup);
}
OnServerClick(EventArgs.Empty);
}
}
}

View File

@@ -0,0 +1,44 @@
//------------------------------------------------------------------------------
// <copyright file="HtmlArea.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.HtmlControls {
using System.ComponentModel;
using System.Web;
using System.Web.UI;
[ControlBuilderAttribute(typeof(HtmlEmptyTagControlBuilder))]
public class HtmlArea : HtmlControl {
public HtmlArea() : base("area") {
}
[
WebCategory("Behavior"),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
UrlProperty()
]
public string Href {
get {
string s = Attributes["href"];
return s ?? String.Empty;
}
set {
Attributes["href"] = MapStringAttributeToString(value);
}
}
/*
* Override to process href attribute
*/
protected override void RenderAttributes(HtmlTextWriter writer) {
PreProcessRelativeReferenceAttribute(writer, "href");
base.RenderAttributes(writer);
writer.Write(" /");
}
}
}

View File

@@ -0,0 +1,60 @@
//------------------------------------------------------------------------------
// <copyright file="HtmlAudio.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.HtmlControls {
using System.ComponentModel;
using System.Web;
using System.Web.UI;
/// <devdoc>
/// <para>
/// The <see langword='HtmlAudio'/>
/// class defines the methods, properties, and events
/// for the HtmlAudio server control.
/// This class provides programmatic access on the server to
/// the HTML 5 &lt;audio&gt; element.
/// </para>
/// </devdoc>
public class HtmlAudio : HtmlContainerControl {
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.Web.UI.HtmlControls.HtmlAudio'/> class.</para>
/// </devdoc>
public HtmlAudio()
: base("audio") {
}
/// <devdoc>
/// <para>
/// Gets or sets the name of and path to the video file to be displayed. This can be an absolute or relative path.
/// </para>
/// </devdoc>
[
WebCategory("Behavior"),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
UrlProperty()
]
public string Src {
get {
string s = Attributes["src"];
return s ?? String.Empty;
}
set {
Attributes["src"] = MapStringAttributeToString(value);
}
}
/*
* Override to process src attribute
*/
protected override void RenderAttributes(HtmlTextWriter writer) {
PreProcessRelativeReferenceAttribute(writer, "src");
base.RenderAttributes(writer);
}
}
}

View File

@@ -0,0 +1,167 @@
//------------------------------------------------------------------------------
// <copyright file="HtmlButton.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
* HtmlButton.cs
*
* Copyright (c) 2000 Microsoft Corporation
*/
namespace System.Web.UI.HtmlControls {
using System.ComponentModel;
using System;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Security.Permissions;
/// <devdoc>
/// <para>The <see langword='HtmlButton'/>
/// class defines the methods, properties and events for the
/// <see langword='HtmlButton'/>
/// control. This
/// class allows programmatic access to the HTML &lt;button&gt; element
/// on the server.</para>
/// </devdoc>
[
DefaultEvent("ServerClick"),
SupportsEventValidation,
]
public class HtmlButton : HtmlContainerControl, IPostBackEventHandler {
private static readonly object EventServerClick = new object();
/*
* Creates an intrinsic Html BUTTON control.
*/
/// <devdoc>
/// <para>Initializes a new instance of a <see cref='System.Web.UI.HtmlControls.HtmlButton'/> class.</para>
/// </devdoc>
public HtmlButton() : base("button") {
}
/// <devdoc>
/// <para>Gets or sets whether pressing the button causes page validation to fire. This defaults to True so that when
/// using validation controls, the validation state of all controls are updated when the button is clicked, both
/// on the client and the server. Setting this to False is useful when defining a cancel or reset button on a page
/// that has validators.</para>
/// </devdoc>
[
WebCategory("Behavior"),
DefaultValue(true),
]
public virtual bool CausesValidation {
get {
object b = ViewState["CausesValidation"];
return((b == null) ? true : (bool)b);
}
set {
ViewState["CausesValidation"] = value;
}
}
[
WebCategory("Behavior"),
DefaultValue(""),
WebSysDescription(SR.PostBackControl_ValidationGroup)
]
public virtual string ValidationGroup {
get {
string s = (string)ViewState["ValidationGroup"];
return((s == null) ? String.Empty : s);
}
set {
ViewState["ValidationGroup"] = value;
}
}
/// <devdoc>
/// <para>Occurs when the user clicks an <see cref='System.Web.UI.HtmlControls.HtmlButton'/> control on the
/// browser.</para>
/// </devdoc>
[
WebCategory("Action"),
WebSysDescription(SR.HtmlControl_OnServerClick)
]
public event EventHandler ServerClick {
add {
Events.AddHandler(EventServerClick, value);
}
remove {
Events.RemoveHandler(EventServerClick, value);
}
}
/// <internalonly/>
protected internal override void OnPreRender(EventArgs e) {
base.OnPreRender(e);
if (Page != null && Events[EventServerClick] != null)
Page.RegisterPostBackScript();
}
/*
* Override to generate postback code for onclick.
*/
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected override void RenderAttributes(HtmlTextWriter writer) {
bool submitsProgramatically = (Events[EventServerClick] != null);
if (Page != null && submitsProgramatically) {
Util.WriteOnClickAttribute(
writer, this, false, true,
(CausesValidation && Page.GetValidators(ValidationGroup).Count > 0),
ValidationGroup);
}
base.RenderAttributes(writer);
}
/// <devdoc>
/// <para>Raises the <see langword='ServerClick'/>
/// event.</para>
/// </devdoc>
protected virtual void OnServerClick(EventArgs e) {
EventHandler handler = (EventHandler)Events[EventServerClick];
if (handler != null) handler(this, e);
}
/*
* Method of IPostBackDataHandler interface to raise events on post back.
* Button fires an OnServerClick event.
*/
/// <internalonly/>
/// <devdoc>
/// </devdoc>
void IPostBackEventHandler.RaisePostBackEvent(string eventArgument) {
RaisePostBackEvent(eventArgument);
}
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected virtual void RaisePostBackEvent(string eventArgument) {
ValidateEvent(UniqueID, eventArgument);
if (CausesValidation) {
Page.Validate(ValidationGroup);
}
OnServerClick(EventArgs.Empty);
}
}
}

View File

@@ -0,0 +1,181 @@
//------------------------------------------------------------------------------
// <copyright file="HtmlContainerControl.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.HtmlControls {
using System.Runtime.Serialization.Formatters;
using System;
using System.Collections;
using System.ComponentModel;
using System.IO;
using System.Web.UI;
using System.Security.Permissions;
/*
* A control representing an intrinsic Html tag.
*/
/// <devdoc>
/// <para>The <see langword='HtmlContainerControl'/>
/// class defines the methods,
/// properties and events
/// available to all Html Server controls that must have a
/// closing tag.</para>
/// </devdoc>
abstract public class HtmlContainerControl : HtmlControl {
/*
* Creates a new WebControl
*/
/// <devdoc>
/// <para>Initializes a new instance of a <see cref='System.Web.UI.HtmlControls.HtmlContainerControl'/> class using
/// default values.</para>
/// </devdoc>
protected HtmlContainerControl() : this("span") {
}
/*
* Creates a new HtmlContainerControl
*/
/// <devdoc>
/// <para>Initializes a new instance of a <see cref='System.Web.UI.HtmlControls.HtmlContainerControl'/> class using the
/// specified string.</para>
/// </devdoc>
public HtmlContainerControl(string tag) : base(tag) {
}
/*
* The inner html content between the begin and end tag.
* A set will replace any existing child controls with a single literal.
* A get will return the text of a single literal child OR
* will throw an exception if there are no children, more than one
* child, or the single child is not a literal.
*/
/// <devdoc>
/// <para>
/// Gets or sets the
/// content found between the opening and closing tags of the specified HTML server control.
/// </para>
/// </devdoc>
[
Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
HtmlControlPersistable(false),
]
public virtual string InnerHtml {
get {
if (IsLiteralContent())
return((LiteralControl) Controls[0]).Text;
else if (HasControls() && (Controls.Count == 1) && Controls[0] is DataBoundLiteralControl)
return ((DataBoundLiteralControl) Controls[0]).Text;
else {
if (Controls.Count == 0)
return String.Empty;
throw new HttpException(SR.GetString(SR.Inner_Content_not_literal, ID));
}
}
set {
Controls.Clear();
Controls.Add(new LiteralControl(value));
ViewState["innerhtml"] = value;
}
}
/*
* The inner text content between the begin and end tag.
* A set will replace any existing child controls with a single literal.
* A get will return the text of a single literal child OR
* will throw an exception if there are no children, more than one child, or
* the single child is not a literal.
*/
/// <devdoc>
/// <para>
/// Gets or sets all text between the opening and closing tags
/// of the specified HTML server control.
/// </para>
/// </devdoc>
[
Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
HtmlControlPersistable(false),
]
public virtual string InnerText {
get {
return HttpUtility.HtmlDecode(InnerHtml);
}
set {
InnerHtml = HttpUtility.HtmlEncode(value);
}
}
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
protected override ControlCollection CreateControlCollection() {
return new ControlCollection(this);
}
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected override void LoadViewState(object savedState) {
if (savedState != null) {
base.LoadViewState(savedState);
string s = (string)ViewState["innerhtml"];
// Dev10 703061 If InnerHtml is set, we want to clear out any child controls, but not dirty viewstate
if (s != null) {
Controls.Clear();
Controls.Add(new LiteralControl(s));
}
}
}
/*
* Render the control into the given writer.
*/
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected internal override void Render(HtmlTextWriter writer) {
RenderBeginTag(writer);
RenderChildren(writer);
RenderEndTag(writer);
}
/*
* Override to prevent InnerHtml from being rendered as an attribute.
*/
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected override void RenderAttributes(HtmlTextWriter writer) {
ViewState.Remove("innerhtml");
base.RenderAttributes(writer);
}
/*
* Render the end tag, &lt;/TAGNAME&gt;.
*/
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected virtual void RenderEndTag(HtmlTextWriter writer) {
writer.WriteEndTag(TagName);
}
}
}

View File

@@ -0,0 +1,295 @@
//------------------------------------------------------------------------------
// <copyright file="HtmlControl.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
* HtmlControl.cs
*
* Copyright (c) 2000 Microsoft Corporation
*/
namespace System.Web.UI.HtmlControls {
using System;
using System.Globalization;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO;
using System.Web.Util;
using System.Web.UI;
using AttributeCollection = System.Web.UI.AttributeCollection;
using System.Security.Permissions;
/*
* An abstract base class representing an intrinsic Html tag that
* is not represented by both a begin and end tag, for example
* INPUT or IMG.
*/
/// <devdoc>
/// <para>
/// The <see langword='HtmlControl'/>
/// class defines the methods, properties, and events
/// common to all HTML Server controls in the Web Forms page framework.
/// </para>
/// </devdoc>
[
Designer("System.Web.UI.Design.HtmlIntrinsicControlDesigner, " + AssemblyRef.SystemDesign),
ToolboxItem(false)
]
abstract public class HtmlControl : Control, IAttributeAccessor {
internal string _tagName;
private AttributeCollection _attributes;
/// <devdoc>
/// </devdoc>
protected HtmlControl() : this("span") {
}
/// <devdoc>
/// </devdoc>
protected HtmlControl(string tag) {
_tagName = tag;
}
/*
* Access to collection of Attributes.
*/
/// <devdoc>
/// <para>
/// Gets all attribute name/value pairs expressed on a
/// server control tag within a selected ASP.NET page.
/// </para>
/// </devdoc>
[
Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
]
public AttributeCollection Attributes {
[System.Runtime.TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
get {
if (_attributes == null)
_attributes = new AttributeCollection(ViewState);
return _attributes;
}
}
/*
* Access to collection of styles.
*/
/// <devdoc>
/// <para>
/// Gets all
/// cascading style sheet (CSS) properties that
/// are applied
/// to a specified HTML Server control in an .aspx
/// file.
/// </para>
/// </devdoc>
[
Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
]
public CssStyleCollection Style {
get {
return Attributes.CssStyle;
}
}
/*
* Property to get name of tag.
*/
/// <devdoc>
/// <para>
/// Gets the element name of a tag that contains a runat=server
/// attribute/value pair.
/// </para>
/// </devdoc>
[
WebCategory("Appearance"),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
public virtual string TagName {
get { return _tagName;}
}
/*
* Disabled property.
*/
/// <devdoc>
/// <para>
/// Gets or sets
/// a value indicating whether ---- attribute is included when a server
/// control is rendered.
/// </para>
/// </devdoc>
[
WebCategory("Behavior"),
DefaultValue(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
TypeConverter(typeof(MinimizableAttributeTypeConverter))
]
public bool Disabled {
get {
string s = Attributes["disabled"];
return((s != null) ? (s.Equals("disabled")) : false);
}
set {
if (value)
Attributes["disabled"] = "disabled";
else
Attributes["disabled"] = null;
}
}
/// <devdoc>
/// </devdoc>
/// <internalonly/>
protected override bool ViewStateIgnoresCase {
get {
return true;
}
}
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
protected override ControlCollection CreateControlCollection() {
return new EmptyControlCollection(this);
}
/*
* Render the control into the given writer.
*/
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected internal override void Render(HtmlTextWriter writer) {
RenderBeginTag(writer);
}
/*
* Render only the attributes, attr1=value1 attr2=value2 ...
*/
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected virtual void RenderAttributes(HtmlTextWriter writer) {
if (ID != null)
writer.WriteAttribute("id", ClientID);
Attributes.Render(writer);
}
/*
* Render the begin tag and its attributes, &lt;TAGNAME attr1=value1 attr2=value2&gt;.
*/
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected virtual void RenderBeginTag(HtmlTextWriter writer) {
writer.WriteBeginTag(TagName);
RenderAttributes(writer);
writer.Write(HtmlTextWriter.TagRightChar);
}
/*
* HtmlControls support generic access to Attributes.
*/
/// <internalonly/>
/// <devdoc>
/// </devdoc>
string IAttributeAccessor.GetAttribute(string name) {
return GetAttribute(name);
}
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected virtual string GetAttribute(string name) {
return Attributes[name];
}
/*
* HtmlControls support generic access to Attributes.
*/
/// <internalonly/>
/// <devdoc>
/// </devdoc>
void IAttributeAccessor.SetAttribute(string name, string value) {
SetAttribute(name, value);
}
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected virtual void SetAttribute(string name, string value) {
Attributes[name] = value;
}
internal void PreProcessRelativeReferenceAttribute(HtmlTextWriter writer,
string attribName) {
string url = Attributes[attribName];
// Don't do anything if it's not specified
if (String.IsNullOrEmpty(url))
return;
try {
url = ResolveClientUrl(url);
}
catch (Exception e) {
throw new HttpException(SR.GetString(SR.Property_Had_Malformed_Url, attribName, e.Message));
}
writer.WriteAttribute(attribName, url);
Attributes.Remove(attribName);
}
internal static string MapStringAttributeToString(string s) {
// If it's an empty string, change it to null
if (s != null && s.Length == 0)
return null;
// Otherwise, just return the input
return s;
}
internal static string MapIntegerAttributeToString(int n) {
// If it's -1, change it to null
if (n == -1)
return null;
// Otherwise, convert the integer to a string
return n.ToString(NumberFormatInfo.InvariantInfo);
}
}
}

View File

@@ -0,0 +1,42 @@
//------------------------------------------------------------------------------
// <copyright file="HtmlElement.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.HtmlControls {
using System.ComponentModel;
using System.Web;
using System.Web.UI;
public class HtmlElement : HtmlContainerControl {
public HtmlElement() : base("html") {
}
[
WebCategory("Behavior"),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
UrlProperty()
]
public string Manifest {
get {
string s = Attributes["manifest"];
return s ?? String.Empty;
}
set {
Attributes["manifest"] = MapStringAttributeToString(value);
}
}
/*
* Override to process manifest attribute
*/
protected override void RenderAttributes(HtmlTextWriter writer) {
PreProcessRelativeReferenceAttribute(writer, "manifest");
base.RenderAttributes(writer);
}
}
}

View File

@@ -0,0 +1,42 @@
//------------------------------------------------------------------------------
// <copyright file="HtmlEmbed.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.HtmlControls {
using System.ComponentModel;
using System.Web;
using System.Web.UI;
public class HtmlEmbed : HtmlContainerControl {
public HtmlEmbed() : base("embed") {
}
[
WebCategory("Behavior"),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
UrlProperty()
]
public string Src {
get {
string s = Attributes["src"];
return s ?? String.Empty;
}
set {
Attributes["src"] = MapStringAttributeToString(value);
}
}
/*
* Override to process src attribute
*/
protected override void RenderAttributes(HtmlTextWriter writer) {
PreProcessRelativeReferenceAttribute(writer, "src");
base.RenderAttributes(writer);
}
}
}

View File

@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <copyright file="HtmlEmptyTagControlBuilder.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.HtmlControls {
using System;
using System.Web.UI;
/// <devdoc>
/// Used as ControlBuilder for controls that do not have a body or end
/// tag, for example, INPUT and IMG.
/// </devdoc>
public sealed class HtmlEmptyTagControlBuilder : ControlBuilder {
// <devdoc>
// Indicate that the control does not have a body or end tag.
// </devdoc>
public override bool HasBody() {
return false;
}
}
}

View File

@@ -0,0 +1,81 @@
//------------------------------------------------------------------------------
// <copyright file="HtmlGenericControl.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
* HtmlGenericControl.cs
*
* Copyright (c) 2000 Microsoft Corporation
*/
namespace System.Web.UI.HtmlControls {
using System;
using System.Collections;
using System.ComponentModel;
using System.IO;
using System.Web.UI;
/*
* A control representing an unknown Html tag.
*/
/// <devdoc>
/// <para>
/// The <see langword='HtmlGenericControl'/> class defines the methods,
/// properties, and events for all HTML Server control tags not represented by a
/// specific class.
/// </para>
/// </devdoc>
[ConstructorNeedsTag(true)]
public class HtmlGenericControl : HtmlContainerControl {
/*
* Creates a new WebControl
*/
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.Web.UI.HtmlControls.HtmlGenericControl'/> class with default
/// values.</para>
/// </devdoc>
public HtmlGenericControl() : this("span") {
}
/*
* Creates a new HtmlGenericControl
*/
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.Web.UI.HtmlControls.HtmlGenericControl'/> class using the specified
/// string.</para>
/// </devdoc>
public HtmlGenericControl(string tag) {
if (tag == null)
tag = String.Empty;
_tagName = tag;
}
/*
* Property to get name of tag.
*/
/// <devdoc>
/// <para>
/// Gets or sets the element name of a tag that contains a
/// runat="server" attribute/value pair.
/// </para>
/// </devdoc>
[
WebCategory("Appearance"),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
new public string TagName {
get { return _tagName;}
set {_tagName = value;}
}
}
}

View File

@@ -0,0 +1,391 @@
//------------------------------------------------------------------------------
// <copyright file="HtmlHead.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.HtmlControls {
using System;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Permissions;
public class HtmlHeadBuilder : ControlBuilder {
public override Type GetChildControlType(string tagName, IDictionary attribs) {
if (String.Equals(tagName, "title", StringComparison.OrdinalIgnoreCase))
return typeof(HtmlTitle);
if (String.Equals(tagName, "link", StringComparison.OrdinalIgnoreCase))
return typeof(HtmlLink);
if (String.Equals(tagName, "meta", StringComparison.OrdinalIgnoreCase))
return typeof(HtmlMeta);
return null;
}
public override bool AllowWhitespaceLiterals() {
return false;
}
}
/// <devdoc>
/// Represents the HEAD element.
/// </devdoc>
[
ControlBuilderAttribute(typeof(HtmlHeadBuilder))
]
public sealed class HtmlHead : HtmlGenericControl {
private StyleSheetInternal _styleSheet;
private HtmlTitle _title;
private String _cachedTitleText;
private HtmlMeta _description;
private String _cachedDescription;
private HtmlMeta _keywords;
private String _cachedKeywords;
/// <devdoc>
/// Initializes an instance of an HtmlHead class.
/// </devdoc>
public HtmlHead() : base("head") {
}
public HtmlHead(string tag) : base(tag) {
if (tag == null) {
tag = String.Empty;
}
_tagName = tag;
}
public IStyleSheet StyleSheet {
get {
if (_styleSheet == null) {
_styleSheet = new StyleSheetInternal(this);
}
return _styleSheet;
}
}
public String Title {
get {
if (_title == null) {
return _cachedTitleText;
}
return _title.Text;
}
set {
if (_title == null) {
// Side effect of adding a title to the control assigns _title
_cachedTitleText = value;
}
else {
_title.Text = value;
}
}
}
public String Description {
get {
if (_description == null) {
return _cachedDescription;
}
return _description.Content;
}
set {
if (_description == null) {
// Side effect of adding a description to the control assigns _description
_cachedDescription = value;
}
else {
_description.Content = value;
}
}
}
public String Keywords {
get {
if (_keywords == null) {
return _cachedKeywords;
}
return _keywords.Content;
}
set {
if (_keywords == null) {
// Side effect of adding a title to the control assigns _title
_cachedKeywords = value;
}
else {
_keywords.Content = value;
}
}
}
protected internal override void AddedControl(Control control, int index) {
base.AddedControl(control, index);
if (control is HtmlTitle) {
if (_title != null) {
throw new HttpException(SR.GetString(SR.HtmlHead_OnlyOneTitleAllowed));
}
_title = (HtmlTitle)control;
}
else if (control is HtmlMeta) {
// We will only use the first matching meta tag per, and ignore any others
HtmlMeta meta = (HtmlMeta)control;
if (_description == null && string.Equals(meta.Name, "description", StringComparison.OrdinalIgnoreCase)) {
_description = meta;
}
else if (_keywords == null && string.Equals(meta.Name, "keywords", StringComparison.OrdinalIgnoreCase)) {
_keywords = meta;
}
}
}
/// <internalonly/>
/// <devdoc>
/// Allows the HEAD element to register itself with the page.
/// </devdoc>
protected internal override void OnInit(EventArgs e) {
base.OnInit(e);
Page p = Page;
if (p == null) {
throw new HttpException(SR.GetString(SR.Head_Needs_Page));
}
if (p.Header != null) {
throw new HttpException(SR.GetString(SR.HtmlHead_OnlyOneHeadAllowed));
}
p.SetHeader(this);
}
internal void RegisterCssStyleString(string outputString) {
((StyleSheetInternal)StyleSheet).CSSStyleString = outputString;
}
protected internal override void RemovedControl(Control control) {
base.RemovedControl(control);
if (control is HtmlTitle) {
_title = null;
}
// There can be many meta tags, so we only clear it if its the correct meta
else if (control == _description) {
_description = null;
}
else if (control == _keywords) {
_keywords = null;
}
}
/// <internalonly/>
/// <devdoc>
/// Notifies the Page when the HEAD is being rendered.
/// </devdoc>
protected internal override void RenderChildren(HtmlTextWriter writer) {
base.RenderChildren(writer);
if (_title == null) {
// Always render out a <title> tag since it is required for xhtml 1.1 compliance
writer.RenderBeginTag(HtmlTextWriterTag.Title);
if (_cachedTitleText != null) {
writer.Write(_cachedTitleText);
}
writer.RenderEndTag();
}
if (_description == null && !String.IsNullOrEmpty(_cachedDescription)) {
// Go ahead and render out a meta tag if they set description but don't have a meta tag
writer.AddAttribute(HtmlTextWriterAttribute.Name, "description");
writer.AddAttribute(HtmlTextWriterAttribute.Content, _cachedDescription);
writer.RenderBeginTag(HtmlTextWriterTag.Meta);
writer.RenderEndTag();
}
if (_keywords == null && !String.IsNullOrEmpty(_cachedKeywords)) {
// Go ahead and render out a meta tag if they set keywords but don't have a meta tag
writer.AddAttribute(HtmlTextWriterAttribute.Name, "keywords");
writer.AddAttribute(HtmlTextWriterAttribute.Content, _cachedKeywords);
writer.RenderBeginTag(HtmlTextWriterTag.Meta);
writer.RenderEndTag();
}
if ((string)Page.Request.Browser["requiresXhtmlCssSuppression"] != "true") {
RenderStyleSheet(writer);
}
}
internal void RenderStyleSheet(HtmlTextWriter writer) {
if(_styleSheet != null) {
_styleSheet.Render(writer);
}
}
internal static void RenderCssRule(CssTextWriter cssWriter, string selector,
Style style, IUrlResolutionService urlResolver) {
cssWriter.WriteBeginCssRule(selector);
CssStyleCollection attrs = style.GetStyleAttributes(urlResolver);
attrs.Render(cssWriter);
cssWriter.WriteEndCssRule();
}
/// <devdoc>
/// Implements the IStyleSheet interface to represent an embedded
/// style sheet within the HEAD element.
/// </devdoc>
private sealed class StyleSheetInternal : IStyleSheet, IUrlResolutionService {
private HtmlHead _owner;
private ArrayList _styles;
private ArrayList _selectorStyles;
private int _autoGenCount;
public StyleSheetInternal(HtmlHead owner) {
_owner = owner;
}
// CssStyleString registered by the PartialCachingControl
private string _cssStyleString;
internal string CSSStyleString {
get {
return _cssStyleString;
}
set {
_cssStyleString = value;
}
}
public void Render(HtmlTextWriter writer) {
if ((_styles == null) && (_selectorStyles == null) && CSSStyleString == null) {
return;
}
writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/css");
writer.RenderBeginTag(HtmlTextWriterTag.Style);
CssTextWriter cssWriter = new CssTextWriter(writer);
if (_styles != null) {
for (int i = 0; i < _styles.Count; i++) {
StyleInfo si = (StyleInfo)_styles[i];
string cssClass = si.style.RegisteredCssClass;
if (cssClass.Length != 0) {
RenderCssRule(cssWriter, "." + cssClass, si.style, si.urlResolver);
}
}
}
if (_selectorStyles != null) {
for (int i = 0; i < _selectorStyles.Count; i++) {
SelectorStyleInfo si = (SelectorStyleInfo)_selectorStyles[i];
RenderCssRule(cssWriter, si.selector, si.style, si.urlResolver);
}
}
if (CSSStyleString != null) {
writer.Write(CSSStyleString);
}
writer.RenderEndTag();
}
#region Implementation of IStyleSheet
void IStyleSheet.CreateStyleRule(Style style, IUrlResolutionService urlResolver, string selector) {
if (style == null) {
throw new ArgumentNullException("style");
}
if (selector.Length == 0) {
throw new ArgumentNullException("selector");
}
if (_selectorStyles == null) {
_selectorStyles = new ArrayList();
}
if (urlResolver == null) {
urlResolver = this;
}
SelectorStyleInfo styleInfo = new SelectorStyleInfo();
styleInfo.selector = selector;
styleInfo.style = style;
styleInfo.urlResolver = urlResolver;
_selectorStyles.Add(styleInfo);
Page page = _owner.Page;
// If there are any partial caching controls on the stack, forward the styleInfo to them
if (page.PartialCachingControlStack != null) {
foreach (BasePartialCachingControl c in page.PartialCachingControlStack) {
c.RegisterStyleInfo(styleInfo);
}
}
}
void IStyleSheet.RegisterStyle(Style style, IUrlResolutionService urlResolver) {
if (style == null) {
throw new ArgumentNullException("style");
}
if (_styles == null) {
_styles = new ArrayList();
}
else if (style.RegisteredCssClass.Length != 0) {
// if it's already registered, throw an exception
throw new InvalidOperationException(SR.GetString(SR.HtmlHead_StyleAlreadyRegistered));
}
if (urlResolver == null) {
urlResolver = this;
}
StyleInfo styleInfo = new StyleInfo();
styleInfo.style = style;
styleInfo.urlResolver = urlResolver;
int index = _autoGenCount++;
string name = "aspnet_s" + index.ToString(NumberFormatInfo.InvariantInfo);
style.SetRegisteredCssClass(name);
_styles.Add(styleInfo);
}
#endregion
#region Implementation of IUrlResolutionService
string IUrlResolutionService.ResolveClientUrl(string relativeUrl) {
return _owner.ResolveClientUrl(relativeUrl);
}
#endregion
private sealed class StyleInfo {
public Style style;
public IUrlResolutionService urlResolver;
}
}
}
internal sealed class SelectorStyleInfo {
public string selector;
public Style style;
public IUrlResolutionService urlResolver;
}
}

View File

@@ -0,0 +1,42 @@
//------------------------------------------------------------------------------
// <copyright file="HtmlIframe.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.HtmlControls {
using System.ComponentModel;
using System.Web;
using System.Web.UI;
public class HtmlIframe : HtmlContainerControl {
public HtmlIframe() : base("iframe") {
}
[
WebCategory("Behavior"),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
UrlProperty()
]
public string Src {
get {
string s = Attributes["src"];
return s ?? String.Empty;
}
set {
Attributes["src"] = MapStringAttributeToString(value);
}
}
/*
* Override to process src attribute
*/
protected override void RenderAttributes(HtmlTextWriter writer) {
PreProcessRelativeReferenceAttribute(writer, "src");
base.RenderAttributes(writer);
}
}
}

View File

@@ -0,0 +1,222 @@
//------------------------------------------------------------------------------
// <copyright file="HtmlImage.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
* HtmlImage.cs
*
* Copyright (c) 2000 Microsoft Corporation
*/
namespace System.Web.UI.HtmlControls {
using System;
using System.ComponentModel;
using System.Globalization;
using System.Web;
using System.Web.UI;
using System.Web.Util;
/// <devdoc>
/// <para>
/// The <see langword='HtmlImage'/>
/// class defines the methods, properties, and events
/// for the HtmlImage server control.
/// This class provides programmatic access on the server to
/// the HTML &lt;img&gt; element.
/// </para>
/// </devdoc>
[
ControlBuilderAttribute(typeof(HtmlEmptyTagControlBuilder))
]
public class HtmlImage : HtmlControl {
/*
* Creates an intrinsic Html IMG control.
*/
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.Web.UI.HtmlControls.HtmlImage'/> class.</para>
/// </devdoc>
public HtmlImage() : base("img") {
}
/*
* Alt property
*/
/// <devdoc>
/// <para>
/// Gets or sets the alternative caption that the
/// browser displays if image is either unavailable or has not been downloaded yet.
/// </para>
/// </devdoc>
[
WebCategory("Appearance"),
Localizable(true),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
public string Alt {
get {
string s = Attributes["alt"];
return((s != null) ? s : String.Empty);
}
set {
// Dev11 #382229: <img> elements must have 'alt' attributes to pass W3 validation.
// An empty string is an acceptable default value for these attributes.
if (RenderingCompatibility >= VersionUtil.Framework45) {
Attributes["alt"] = value;
}
else {
Attributes["alt"] = MapStringAttributeToString(value);
}
}
}
/*
* Align property
*/
/// <devdoc>
/// <para>Gets or sets the alignment of the image with
/// surrounding text.</para>
/// </devdoc>
[
WebCategory("Appearance"),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
public string Align {
get {
string s = Attributes["align"];
return((s != null) ? s : String.Empty);
}
set {
Attributes["align"] = MapStringAttributeToString(value);
}
}
/*
* Border property, size of border in pixels.
*/
/// <devdoc>
/// <para>
/// Gets or sets the width of image border, in pixels.
/// </para>
/// </devdoc>
[
WebCategory("Appearance"),
DefaultValue(0),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
public int Border {
get {
string s = Attributes["border"];
return((s != null) ? Int32.Parse(s, CultureInfo.InvariantCulture) : -1);
}
set {
Attributes["border"] = MapIntegerAttributeToString(value);
}
}
/*
* Height property
*/
/// <devdoc>
/// <para>
/// Gets or sets
/// the height of the image. By default, this is expressed in
/// pixels,
/// but can be a expressed as a percentage.
/// </para>
/// </devdoc>
[
WebCategory("Layout"),
DefaultValue(100),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
public int Height {
get {
string s = Attributes["height"];
return((s != null) ? Int32.Parse(s, CultureInfo.InvariantCulture) : -1);
}
set {
Attributes["height"] = MapIntegerAttributeToString(value);
}
}
/*
* Src property.
*/
/// <devdoc>
/// <para>
/// Gets or sets the name of and path to the
/// image file to be displayed. This can be an absolute or
/// relative path.
/// </para>
/// </devdoc>
[
WebCategory("Behavior"),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
UrlProperty()
]
public string Src {
get {
string s = Attributes["src"];
return((s != null) ? s : String.Empty);
}
set {
Attributes["src"] = MapStringAttributeToString(value);
}
}
/*
* Width property
*/
/// <devdoc>
/// <para>
/// Gets or sets the width of the image. By default, this is
/// expressed in pixels,
/// but can be a expressed as a percentage.
/// </para>
/// </devdoc>
[
WebCategory("Layout"),
DefaultValue(100),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
public int Width {
get {
string s = Attributes["width"];
return((s != null) ? Int32.Parse(s, CultureInfo.InvariantCulture) : -1);
}
set {
Attributes["width"] = MapIntegerAttributeToString(value);
}
}
/*
* Override to render unique name attribute.
* The name attribute is owned by the framework.
*/
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected override void RenderAttributes(HtmlTextWriter writer) {
PreProcessRelativeReferenceAttribute(writer, "src");
base.RenderAttributes(writer);
writer.Write(" /");
}
}
}

View File

@@ -0,0 +1,194 @@
//------------------------------------------------------------------------------
// <copyright file="HtmlInputButton.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
* HtmlInputButton.cs
*
* Copyright (c) 2000 Microsoft Corporation
*/
namespace System.Web.UI.HtmlControls {
using System;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Globalization;
using System.Security.Permissions;
/// <devdoc>
/// <para>
/// The <see langword='HtmlInputButton'/> class defines the methods,
/// properties, and events for the HTML Input Button control. This class allows
/// programmatic access to the HTML &lt;input type=
/// button&gt;, &lt;input type=
/// submit&gt;,and &lt;input
/// type=
/// reset&gt; elements on
/// the server.
/// </para>
/// </devdoc>
[
DefaultEvent("ServerClick"),
SupportsEventValidation,
]
public class HtmlInputButton : HtmlInputControl, IPostBackEventHandler {
private static readonly object EventServerClick = new object();
/*
* Creates an intrinsic Html INPUT type=button control.
*/
/// <devdoc>
/// <para>Initializes a new instance of a <see cref='System.Web.UI.HtmlControls.HtmlInputButton'/> class using
/// default values.</para>
/// </devdoc>
public HtmlInputButton() : base("button") {
}
/*
* Creates an intrinsic Html INPUT type=button,submit,reset control.
*/
/// <devdoc>
/// <para>Initializes a new instance of a <see cref='System.Web.UI.HtmlControls.HtmlInputButton'/> class using the
/// specified string.</para>
/// </devdoc>
public HtmlInputButton(string type) : base(type) {
}
/// <devdoc>
/// <para>Gets or sets whether pressing the button causes page validation to fire. This defaults to True so that when
/// using validation controls, the validation state of all controls are updated when the button is clicked, both
/// on the client and the server. Setting this to False is useful when defining a cancel or reset button on a page
/// that has validators.</para>
/// </devdoc>
[
WebCategory("Behavior"),
DefaultValue(true),
]
public virtual bool CausesValidation {
get {
object b = ViewState["CausesValidation"];
return((b == null) ? true : (bool)b);
}
set {
ViewState["CausesValidation"] = value;
}
}
[
WebCategory("Behavior"),
DefaultValue(""),
WebSysDescription(SR.PostBackControl_ValidationGroup)
]
public virtual string ValidationGroup {
get {
string s = (string)ViewState["ValidationGroup"];
return((s == null) ? String.Empty : s);
}
set {
ViewState["ValidationGroup"] = value;
}
}
/// <devdoc>
/// <para>
/// Occurs when an HTML Input Button control is clicked on the browser.
/// </para>
/// </devdoc>
[
WebCategory("Action"),
WebSysDescription(SR.HtmlControl_OnServerClick)
]
public event EventHandler ServerClick {
add {
Events.AddHandler(EventServerClick, value);
}
remove {
Events.RemoveHandler(EventServerClick, value);
}
}
/// <internalonly/>
protected internal override void OnPreRender(EventArgs e) {
base.OnPreRender(e);
if (Page != null && Events[EventServerClick] != null) {
Page.RegisterPostBackScript();
}
}
/*
* Override to generate postback code for onclick.
*/
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected override void RenderAttributes(HtmlTextWriter writer) {
RenderAttributesInternal(writer);
base.RenderAttributes(writer); // this must come last because of the self-closing /
}
// VSWhidbey 80882: It needs to be overridden by HtmlInputSubmit
internal virtual void RenderAttributesInternal(HtmlTextWriter writer) {
bool submitsProgramatically = Events[EventServerClick] != null;
if (Page != null) {
if (submitsProgramatically) {
Util.WriteOnClickAttribute(
writer, this, false /* submitsAutomatically */, submitsProgramatically,
(CausesValidation && Page.GetValidators(ValidationGroup).Count > 0),
ValidationGroup);
}
else {
Page.ClientScript.RegisterForEventValidation(UniqueID);
}
}
}
/// <devdoc>
/// <para>Raises the <see langword='ServerClick '/> event.</para>
/// </devdoc>
protected virtual void OnServerClick(EventArgs e) {
EventHandler handler = (EventHandler)Events[EventServerClick];
if (handler != null) handler(this, e);
}
/*
* Method of IPostBackEventHandler interface to raise events on post back.
* Button fires an OnServerClick event.
*/
/// <internalonly/>
/// <devdoc>
/// </devdoc>
void IPostBackEventHandler.RaisePostBackEvent(string eventArgument) {
RaisePostBackEvent(eventArgument);
}
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected virtual void RaisePostBackEvent(string eventArgument) {
ValidateEvent(UniqueID, eventArgument);
if (CausesValidation) {
Page.Validate(ValidationGroup);
}
OnServerClick(EventArgs.Empty);
}
}
}

View File

@@ -0,0 +1,185 @@
//------------------------------------------------------------------------------
// <copyright file="HtmlInputCheckBox.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
* HtmlInputCheckBox.cs
*
* Copyright (c) 2000 Microsoft Corporation
*/
namespace System.Web.UI.HtmlControls {
using System.ComponentModel;
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Globalization;
using System.Web;
using System.Web.UI;
using System.Security.Permissions;
/// <devdoc>
/// <para>
/// The <see langword='HtmlInputCheckBox'/> class defines the methods,
/// properties, and events for the HtmlInputCheckBox control. This class allows
/// programmatic access to the HTML &lt;input type=
/// checkbox&gt;
/// element on the server.
/// </para>
/// </devdoc>
[
DefaultEvent("ServerChange"),
SupportsEventValidation,
]
public class HtmlInputCheckBox : HtmlInputControl, IPostBackDataHandler {
private static readonly object EventServerChange = new object();
/*
* Creates an intrinsic Html INPUT type=checkbox control.
*/
/// <devdoc>
/// <para>Initializes a new instance of a <see cref='System.Web.UI.HtmlControls.HtmlInputCheckBox'/> class.</para>
/// </devdoc>
public HtmlInputCheckBox() : base("checkbox") {
}
/*
* Checked property.
*/
/// <devdoc>
/// <para>Gets or sets a value indicating whether the checkbox is
/// currently selected.</para>
/// </devdoc>
[
WebCategory("Default"),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
TypeConverter(typeof(MinimizableAttributeTypeConverter))
]
public bool Checked {
get {
string s = Attributes["checked"];
return((s != null) ? (s.Equals("checked")) : false);
}
set {
if (value)
Attributes["checked"] = "checked";
else
Attributes["checked"] = null;
}
}
/*
* Adds an event handler for the OnServerChange event.
* value: New handler to install for this event.
*/
/// <devdoc>
/// <para>Occurs when </para>
/// </devdoc>
[
WebCategory("Action"),
WebSysDescription(SR.Control_OnServerCheckChanged)
]
public event EventHandler ServerChange {
add {
Events.AddHandler(EventServerChange, value);
}
remove {
Events.RemoveHandler(EventServerChange, value);
}
}
/*
* This method is invoked just prior to rendering.
*/
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected internal override void OnPreRender(EventArgs e) {
base.OnPreRender(e);
if (Page != null && !Disabled) {
Page.RegisterRequiresPostBack(this);
Page.RegisterEnabledControl(this);
}
// if no change handler, no need to save posted property unless
// we are disabled
if (Events[EventServerChange] == null && !Disabled) {
ViewState.SetItemDirty("checked",false);
}
}
/*
* Method used to raise the OnServerChange event.
*/
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
protected virtual void OnServerChange(EventArgs e) {
// invoke delegates AFTER binding
EventHandler handler = (EventHandler)Events[EventServerChange];
if (handler != null) handler(this, e);
}
/*
* Method of IPostBackDataHandler interface to process posted data.
* Checkbox determines the posted Checked state.
*/
/// <internalonly/>
bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection) {
return LoadPostData(postDataKey, postCollection);
}
/// <internalonly/>
protected virtual bool LoadPostData(string postDataKey, NameValueCollection postCollection) {
string post = postCollection[postDataKey];
bool newValue = !String.IsNullOrEmpty(post);
bool valueChanged = (newValue != Checked);
Checked = newValue;
if (newValue) {
ValidateEvent(postDataKey);
}
return valueChanged;
}
protected override void RenderAttributes(HtmlTextWriter writer) {
base.RenderAttributes(writer);
if (Page != null) {
Page.ClientScript.RegisterForEventValidation(RenderedNameAttribute);
}
}
/*
* Method of IPostBackDataHandler interface which is invoked whenever
* posted data for a control has changed. RadioButton fires an
* OnServerChange event.
*/
/// <internalonly/>
void IPostBackDataHandler.RaisePostDataChangedEvent() {
RaisePostDataChangedEvent();
}
/// <internalonly/>
protected virtual void RaisePostDataChangedEvent() {
OnServerChange(EventArgs.Empty);
}
}
}

View File

@@ -0,0 +1,168 @@
//------------------------------------------------------------------------------
// <copyright file="HtmlInputControl.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
* HtmlInputControl.cs
*
* Copyright (c) 2000 Microsoft Corporation
*/
namespace System.Web.UI.HtmlControls {
using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using Debug=System.Web.Util.Debug;
using System.Security.Permissions;
/*
* An abstract base class representing an intrinsic INPUT tag.
*/
/// <devdoc>
/// <para>
/// The <see langword='HtmlInputControl'/> abstract class defines
/// the methods, properties, and events common to all HTML input controls.
/// These include controls for the &lt;input type=text&gt;, &lt;input
/// type=submit&gt;, and &lt;input type=file&gt; elements.
/// </para>
/// </devdoc>
[
ControlBuilderAttribute(typeof(HtmlEmptyTagControlBuilder))
]
abstract public class HtmlInputControl : HtmlControl {
private string _type;
/*
* Creates a new Input
*/
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.Web.UI.HtmlControls.HtmlInputControl'/> class.</para>
/// </devdoc>
protected HtmlInputControl(string type) : base("input") {
_type = type;
// VSWhidbey 546690: Need to add the type value to the Attributes collection to match Everett behavior.
Attributes["type"] = type;
}
/*
* Name property
*/
/// <devdoc>
/// <para>
/// Gets the value of the HTML
/// Name attribute that will be rendered to the browser.
/// </para>
/// </devdoc>
[
WebCategory("Behavior"),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
public virtual string Name {
get {
return UniqueID;
//string s = Attributes["name"];
//return ((s != null) ? s : String.Empty);
}
set {
//Attributes["name"] = MapStringAttributeToString(value);
}
}
// Value that gets rendered for the Name attribute
internal virtual string RenderedNameAttribute {
get {
return Name;
//string name = Name;
//if (name.Length == 0)
// return UniqueID;
//return name;
}
}
/*
* Value property.
*/
/// <devdoc>
/// <para>
/// Gets or sets the contents of a text box.
/// </para>
/// </devdoc>
[
WebCategory("Appearance"),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
public virtual string Value {
get {
string s = Attributes["value"];
return((s != null) ? s : String.Empty);
}
set {
Attributes["value"] = MapStringAttributeToString(value);
}
}
/*
* Type of input
*/
/// <devdoc>
/// <para>
/// Gets the Type attribute for a particular HTML input control.
/// </para>
/// </devdoc>
[
WebCategory("Behavior"),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
public string Type {
get {
string s = Attributes["type"];
if (!string.IsNullOrEmpty(s)) {
return s;
}
return((_type != null) ? _type : String.Empty);
}
}
/*
* Override to render unique name attribute.
* The name attribute is owned by the framework.
*/
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected override void RenderAttributes(HtmlTextWriter writer) {
writer.WriteAttribute("name", RenderedNameAttribute);
Attributes.Remove("name");
bool removedTypeAttribute = false;
string type = Type;
if (!String.IsNullOrEmpty(type)) {
writer.WriteAttribute("type", type);
Attributes.Remove("type");
removedTypeAttribute = true;
}
base.RenderAttributes(writer);
if (removedTypeAttribute && DesignMode) {
Attributes.Add("type", type);
}
writer.Write(" /");
}
}
}

View File

@@ -0,0 +1,220 @@
//------------------------------------------------------------------------------
// <copyright file="HtmlInputFile.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
* HtmlInputFile.cs
*
* Copyright (c) 2000 Microsoft Corporation
*/
namespace System.Web.UI.HtmlControls {
using System;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.Web;
using System.Web.UI;
using System.Security.Permissions;
/// <devdoc>
/// <para>
/// The <see langword='HtmlInputFile'/> class defines the
/// methods, properties, and events for the <see langword='HtmlInputFile'/> control. This class allows
/// programmatic access to the HTML &lt;input type= file&gt; element on the server.
/// It provides access to the stream, as well as a useful SaveAs functionality
/// provided by the <see cref='System.Web.UI.HtmlControls.HtmlInputFile.PostedFile'/>
/// property.
/// </para>
/// <note type="caution">
/// This class only works if the
/// HtmlForm.Enctype property is set to "multipart/form-data".
/// Also, it does not maintain its
/// state across multiple round trips between browser and server. If the user sets
/// this value after a round trip, the value is lost.
/// </note>
/// </devdoc>
[
ValidationProperty("Value")
]
public class HtmlInputFile : HtmlInputControl, IPostBackDataHandler {
/*
* Creates an intrinsic Html INPUT type=file control.
*/
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.Web.UI.HtmlControls.HtmlInputFile'/> class.</para>
/// </devdoc>
public HtmlInputFile() : base("file") {
}
/*
* Accept type property.
*/
/// <devdoc>
/// <para>
/// Gets
/// or sets a comma-separated list of MIME encodings that
/// can be used to constrain the file types that the browser lets the user
/// select. For example, to restrict the
/// selection to images, the accept value image/* should be specified.
/// </para>
/// </devdoc>
[
WebCategory("Behavior"),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
public string Accept {
get {
string s = Attributes["accept"];
return((s != null) ? s : String.Empty);
}
set {
Attributes["accept"] = MapStringAttributeToString(value);
}
}
/*
* The property for the maximum characters allowed.
*/
/// <devdoc>
/// <para>
/// Gets or sets the
/// maximum length of the file path of the file to upload
/// from the client machine.
/// </para>
/// </devdoc>
[
WebCategory("Behavior"),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
public int MaxLength {
get {
string s = Attributes["maxlength"];
return((s != null) ? Int32.Parse(s, CultureInfo.InvariantCulture) : -1);
}
set {
Attributes["maxlength"] = MapIntegerAttributeToString(value);
}
}
/*
* PostedFile property.
*/
/// <devdoc>
/// <para>Gets access to the uploaded file specified by a client.</para>
/// </devdoc>
[
WebCategory("Default"),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
public HttpPostedFile PostedFile {
get { return Context.Request.Files[RenderedNameAttribute];}
}
/*
* The property for the width in characters.
*/
/// <devdoc>
/// <para>Gets or sets the width of the file-path text box that the
/// browser displays when the <see cref='System.Web.UI.HtmlControls.HtmlInputFile'/>
/// control is used on a page.</para>
/// </devdoc>
[
WebCategory("Appearance"),
DefaultValue(-1),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
public int Size {
get {
string s = Attributes["size"];
return((s != null) ? Int32.Parse(s, CultureInfo.InvariantCulture) : -1);
}
set {
Attributes["size"] = MapIntegerAttributeToString(value);
}
}
// ASURT 122262 : The value property isn't submitted back to us when the a page
// containing this control postsback, so required field validators are broken
// (value would contain the empty string). To fix this, we return the filename.
[
Browsable(false)
]
public override string Value {
get {
HttpPostedFile postedFile = PostedFile;
if (postedFile != null) {
return postedFile.FileName;
}
return String.Empty;
}
set {
// Throw here because setting the value on this tag has no effect on the
// rendering behavior and since we're always returning the posted file's
// filename, we don't want to get into a situation where the user
// sets a value and does not get back that value.
throw new NotSupportedException(SR.GetString(SR.Value_Set_Not_Supported, this.GetType().Name));
}
}
/*
* Method of IPostBackDataHandler interface to process posted data.
*/
/// <internalonly/>
bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection) {
return LoadPostData(postDataKey, postCollection);
}
protected virtual bool LoadPostData(string postDataKey, NameValueCollection postCollection) {
return false;
}
/*
* Method of IPostBackDataHandler interface which is invoked whenever
* posted data for a control has changed. RadioButton fires an
* OnServerChange event.
*/
/// <internalonly/>
void IPostBackDataHandler.RaisePostDataChangedEvent() {
RaisePostDataChangedEvent();
}
protected virtual void RaisePostDataChangedEvent() {
}
/// <devdoc>
/// <para>Raises the <see langword='PreRender'/> event. This method uses event arguments
/// to pass the event data to the control.</para>
/// </devdoc>
protected internal override void OnPreRender(EventArgs e) {
base.OnPreRender(e);
// ASURT 35328: use multipart encoding if no encoding is currently specified
HtmlForm form = Page.Form;
if (form != null && form.Enctype.Length == 0) {
form.Enctype = "multipart/form-data";
}
}
}
}

View File

@@ -0,0 +1,103 @@
//------------------------------------------------------------------------------
// <copyright file="HtmlInputGenericControl.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.HtmlControls {
using System;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Web;
using System.Web.UI;
/// <devdoc>
/// <para>
/// The <see langword='HtmlInputGenericControl'/>
/// class defines the methods, properties, and events for the a generic input
/// control. This class allows programmatic access to the HTML5 &lt;input&gt;
/// elements on the server.
/// </para>
/// </devdoc>
[
DefaultEvent("ServerChange"),
ValidationProperty("Value"),
]
public class HtmlInputGenericControl : HtmlInputControl, IPostBackDataHandler {
private static readonly object EventServerChange = new object();
/// <summary>
/// Creates an intrinsic Html INPUT type=text control.
/// </summary>
public HtmlInputGenericControl() : base("text") {
}
/// <summary>
/// Creates an intrinsic Html INPUT control based on its type.
/// </summary>
/// <param name="type">The type of the control</param>
public HtmlInputGenericControl(string type)
: base(type) {
}
[
WebCategory("Action"),
WebSysDescription(SR.HtmlInputText_ServerChange)
]
public event EventHandler ServerChange {
add {
Events.AddHandler(EventServerChange, value);
}
remove {
Events.RemoveHandler(EventServerChange, value);
}
}
/// <summary>
/// Method used to raise the OnServerChange event.
/// </summary>
/// <param name="e">Event</param>
protected virtual void OnServerChange(EventArgs e) {
EventHandler handler = (EventHandler)Events[EventServerChange];
if (handler != null) {
handler(this, e);
}
}
protected internal override void OnPreRender(EventArgs e) {
base.OnPreRender(e);
if (!Disabled && Page != null) {
Page.RegisterEnabledControl(this);
}
}
bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection) {
return LoadPostData(postDataKey, postCollection);
}
protected virtual bool LoadPostData(string postDataKey, NameValueCollection postCollection) {
string current = Value;
string inputString = postCollection.GetValues(postDataKey)[0];
if (!current.Equals(inputString)) {
ValidateEvent(postDataKey);
Value = inputString;
return true;
}
return false;
}
void IPostBackDataHandler.RaisePostDataChangedEvent() {
RaisePostDataChangedEvent();
}
[SuppressMessage("Microsoft.Design", "CA1030:UseEventsWhereAppropriate", Justification = @"Events are being used correctly for RaisePostBackEvent and RaisePostDataChangedEvent.")]
protected virtual void RaisePostDataChangedEvent() {
OnServerChange(EventArgs.Empty);
}
}
}

View File

@@ -0,0 +1,156 @@
//------------------------------------------------------------------------------
// <copyright file="HtmlInputHidden.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
* HtmlInputHidden.cs
*
* Copyright (c) 2000 Microsoft Corporation
*/
namespace System.Web.UI.HtmlControls {
using System.ComponentModel;
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Web;
using System.Web.UI;
using System.Security.Permissions;
/// <devdoc>
/// <para>
/// The <see langword='HtmlInputHidden'/> class defines the methods, properties,
/// and events of the HtmlInputHidden control. This class allows programmatic access
/// to the HTML &lt;input type=hidden&gt; element on the server.
/// </para>
/// </devdoc>
[
DefaultEvent("ServerChange"),
SupportsEventValidation,
]
public class HtmlInputHidden : HtmlInputControl, IPostBackDataHandler {
private static readonly object EventServerChange = new object();
/*
* Creates an intrinsic Html INPUT type=hidden control.
*/
public HtmlInputHidden() : base("hidden") {
}
/// <devdoc>
/// <para>
/// Occurs when the <see langword='HtmlInputHidden'/> control
/// is changed on the server.
/// </para>
/// </devdoc>
[
WebCategory("Action"),
WebSysDescription(SR.HtmlInputHidden_OnServerChange)
]
public event EventHandler ServerChange {
add {
Events.AddHandler(EventServerChange, value);
}
remove {
Events.RemoveHandler(EventServerChange, value);
}
}
/*
* Method used to raise the OnServerChange event.
*/
/// <devdoc>
/// <para>
/// Raised on the server when the <see langword='HtmlInputHidden'/> control
/// changes between postback requests.
/// </para>
/// </devdoc>
protected virtual void OnServerChange(EventArgs e) {
EventHandler handler = (EventHandler)Events[EventServerChange];
if (handler != null) handler(this, e);
}
/*
*
*/
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected internal override void OnPreRender(EventArgs e) {
base.OnPreRender(e);
// if no change handler, no need to save posted property
if (!Disabled) {
if (Events[EventServerChange] == null) {
ViewState.SetItemDirty("value",false);
}
if (Page != null) {
Page.RegisterEnabledControl(this);
}
}
}
/*
* Method of IPostBackDataHandler interface to process posted data.
* InputText process a newly posted value.
*/
/// <internalonly/>
/// <devdoc>
/// </devdoc>
bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection) {
return LoadPostData(postDataKey, postCollection);
}
protected virtual bool LoadPostData(string postDataKey, NameValueCollection postCollection) {
string current = Value;
string text = postCollection.GetValues(postDataKey)[0];
if (!current.Equals(text)) {
ValidateEvent(postDataKey);
Value = text;
return true;
}
return false;
}
protected override void RenderAttributes(HtmlTextWriter writer) {
base.RenderAttributes(writer);
if (Page != null) {
Page.ClientScript.RegisterForEventValidation(RenderedNameAttribute);
}
}
/*
* Method of IPostBackDataHandler interface which is invoked whenever posted data
* for a control has changed. TextBox fires an OnTextChanged event.
*/
/// <internalonly/>
/// <devdoc>
/// </devdoc>
void IPostBackDataHandler.RaisePostDataChangedEvent() {
RaisePostDataChangedEvent();
}
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected virtual void RaisePostDataChangedEvent() {
OnServerChange(EventArgs.Empty);
}
}
}

View File

@@ -0,0 +1,344 @@
//------------------------------------------------------------------------------
// <copyright file="HtmlInputImage.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
* HtmlInputImage.cs
*
* Copyright (c) 2000 Microsoft Corporation
*/
namespace System.Web.UI.HtmlControls {
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Globalization;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Security.Permissions;
/// <devdoc>
/// <para>
/// The <see langword='HtmlInputImage'/> class defines the
/// methods, properties and events for the HtmlInputImage control. This class allows
/// programmatic access to the HTML &lt;input type=
/// image&gt; element on the server.
/// </para>
/// </devdoc>
[
DefaultEvent("ServerClick"),
SupportsEventValidation,
]
public class HtmlInputImage : HtmlInputControl,
IPostBackDataHandler, IPostBackEventHandler {
private static readonly object EventServerClick = new object();
private int _x;
private int _y;
/*
* Creates an intrinsic Html INPUT type=image control.
*/
public HtmlInputImage() : base("image") {
}
/// <devdoc>
/// <para>
/// Gets or sets the image
/// alignment within the form's content flow.
/// </para>
/// </devdoc>
/*
* Align property.
*/
[
WebCategory("Appearance"),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
public string Align {
get {
string s = Attributes["align"];
return((s != null) ? s : String.Empty);
}
set {
Attributes["align"] = MapStringAttributeToString(value);
}
}
/// <devdoc>
/// <para>
/// Gets or sets the alternative text
/// that the browser should display if the image is either unavailable or has not
/// been downloaded yet.
/// </para>
/// </devdoc>
/*
* Alt property.
*/
[
WebCategory("Appearance"),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
Localizable(true)
]
public string Alt {
get {
string s = Attributes["alt"];
return((s != null) ? s : String.Empty);
}
set {
Attributes["alt"] = MapStringAttributeToString(value);
}
}
/// <devdoc>
/// <para>
/// Gets or sets the
/// border width, in pixels, around the image.
/// </para>
/// </devdoc>
/*
* Border property, size of border in pixels.
*/
[
WebCategory("Appearance"),
DefaultValue(-1),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
public int Border {
get {
string s = Attributes["border"];
return((s != null) ? Int32.Parse(s, CultureInfo.InvariantCulture) : -1);
}
set {
Attributes["border"] = MapIntegerAttributeToString(value);
}
}
/// <devdoc>
/// <para>
/// Gets or sets the location of
/// the image file relative to the page on which it is displayed.
/// </para>
/// </devdoc>
/*
* Src property.
*/
[
WebCategory("Appearance"),
DefaultValue(""),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
UrlProperty()
]
public string Src {
get {
string s = Attributes["src"];
return((s != null) ? s : String.Empty);
}
set {
Attributes["src"] = MapStringAttributeToString(value);
}
}
/// <devdoc>
/// <para>Gets or sets whether pressing the button causes page validation to fire. This defaults to True so that when
/// using validation controls, the validation state of all controls are updated when the button is clicked, both
/// on the client and the server. Setting this to False is useful when defining a cancel or reset button on a page
/// that has validators.</para>
/// </devdoc>
[
WebCategory("Behavior"),
DefaultValue(true),
]
public virtual bool CausesValidation {
get {
object b = ViewState["CausesValidation"];
return((b == null) ? true : (bool)b);
}
set {
ViewState["CausesValidation"] = value;
}
}
[
WebCategory("Behavior"),
DefaultValue(""),
WebSysDescription(SR.PostBackControl_ValidationGroup)
]
public virtual string ValidationGroup {
get {
string s = (string)ViewState["ValidationGroup"];
return((s == null) ? String.Empty : s);
}
set {
ViewState["ValidationGroup"] = value;
}
}
/// <devdoc>
/// <para>
/// Occurs on the server when a user clicks an <see langword='HtmlInputImage'/>
/// control.
/// </para>
/// </devdoc>
[
WebCategory("Action"),
WebSysDescription(SR.HtmlInputImage_OnServerClick)
]
public event ImageClickEventHandler ServerClick {
add {
Events.AddHandler(EventServerClick, value);
}
remove {
Events.RemoveHandler(EventServerClick, value);
}
}
/// <internalonly/>
/// <devdoc>
/// </devdoc>
/*
* This method is invoked just prior to rendering.
* Register requires handling postback to determine if image has been clicked.
*/
protected internal override void OnPreRender(EventArgs e) {
base.OnPreRender(e);
if (Page != null) {
if (!Disabled)
Page.RegisterRequiresPostBack(this);
if (CausesValidation)
Page.RegisterPostBackScript();
}
}
/// <devdoc>
/// <para>
/// Raised on the server when a user clicks an <see langword='HtmlInputImage'/>
/// control.
/// </para>
/// </devdoc>
/*
* Method used to raise the OnServerClick event.
*/
protected virtual void OnServerClick(ImageClickEventArgs e) {
ImageClickEventHandler handler = (ImageClickEventHandler)Events[EventServerClick];
if (handler != null) handler(this, e);
}
/// <internalonly/>
/// <devdoc>
/// </devdoc>
/*
* Method of IPostBackEventHandler interface to raise events on post back.
* HtmlInputImage fires an OnServerClick event.
*/
void IPostBackEventHandler.RaisePostBackEvent(string eventArgument) {
RaisePostBackEvent(eventArgument);
}
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected virtual void RaisePostBackEvent(string eventArgument) {
if (CausesValidation) {
Page.Validate(ValidationGroup);
}
OnServerClick(new ImageClickEventArgs(_x, _y));
}
/// <internalonly/>
/// <devdoc>
/// </devdoc>
/*
* Method of IPostBackDataHandler interface to process posted data.
* The image control will check to see if the x and y values were posted,
* which indicates that the image was clicked by the user. The image
* control will then register with the Page that it wants to raise an event
* during the event processing phase.
*/
bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection) {
return LoadPostData(postDataKey, postCollection);
}
protected virtual bool LoadPostData(string postDataKey, NameValueCollection postCollection) {
string postX = postCollection[RenderedNameAttribute + ".x"];
string postY = postCollection[RenderedNameAttribute + ".y"];
if (postX != null && postY != null &&
postX.Length > 0 && postY.Length > 0) {
ValidateEvent(UniqueID);
_x = Int32.Parse(postX, CultureInfo.InvariantCulture);
_y = Int32.Parse(postY, CultureInfo.InvariantCulture);
Page.RegisterRequiresRaiseEvent(this);
}
return false;
}
/// <internalonly/>
/// <devdoc>
/// </devdoc>
/*
* Method of IPostBackDataHandler interface which is invoked whenever posted data
* for a control has changed.
*/
void IPostBackDataHandler.RaisePostDataChangedEvent() {
RaisePostDataChangedEvent();
}
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected virtual void RaisePostDataChangedEvent() {
}
/*
* Override to render unique name attribute.
* The name attribute is owned by the framework.
*/
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected override void RenderAttributes(HtmlTextWriter writer) {
PreProcessRelativeReferenceAttribute(writer, "src");
if (Page != null) {
Util.WriteOnClickAttribute(
writer, this, true, false,
(CausesValidation && Page.GetValidators(ValidationGroup).Count > 0),
ValidationGroup);
}
base.RenderAttributes(writer);
}
}
}

Some files were not shown because too many files have changed in this diff Show More