Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,219 @@
//
// System.Web.UI.HtmlControls.HtmlAnchor.cs
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.ComponentModel;
using System.Security.Permissions;
namespace System.Web.UI.HtmlControls {
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[DefaultEvent ("ServerClick")]
[SupportsEventValidation]
public class HtmlAnchor : HtmlContainerControl, IPostBackEventHandler
{
static readonly object serverClickEvent = new object ();
public HtmlAnchor ()
: base ("a")
{
}
[DefaultValue ("")]
[WebSysDescription("")]
[WebCategory("Action")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[UrlProperty]
public string HRef {
get {
string s = Attributes ["href"];
return (s == null) ? String.Empty : s;
}
set {
if (value == null || value.Length == 0) {
Attributes.Remove ("href");
} else {
Attributes ["href"] = value;
}
}
}
[DefaultValue ("")]
[WebSysDescription("")]
[WebCategory("Navigation")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public string Name {
get {
string s = Attributes ["name"];
return (s == null) ? String.Empty : s;
}
set {
if (value == null || value.Length == 0)
Attributes.Remove ("name");
else
Attributes ["name"] = value;
}
}
[DefaultValue ("")]
[WebSysDescription("")]
[WebCategory("Navigation")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public string Target {
get {
string s = Attributes ["target"];
return (s == null) ? String.Empty : s;
}
set {
if (value == null || value.Length == 0)
Attributes.Remove ("target");
else
Attributes ["target"] = value;
}
}
[DefaultValue ("")]
[WebSysDescription("")]
[WebCategory("Appearance")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[Localizable (true)]
public string Title {
get {
string s = Attributes ["title"];
return (s == null) ? String.Empty : s;
}
set {
if (value == null || value.Length == 0)
Attributes.Remove ("title");
else
Attributes ["title"] = value;
}
}
[DefaultValue (true)]
public virtual bool CausesValidation {
get {
return ViewState.GetBool ("CausesValidation", true);
}
set {
ViewState ["CausesValidation"] = value;
}
}
[DefaultValue ("")]
public virtual string ValidationGroup {
get {
return ViewState.GetString ("ValidationGroup", String.Empty);
}
set {
ViewState ["ValidationGroup"] = value;
}
}
protected internal override void OnPreRender (EventArgs e)
{
base.OnPreRender (e);
}
protected virtual void OnServerClick (EventArgs e)
{
EventHandler serverClick = (EventHandler) Events [serverClickEvent];
if (serverClick != null)
serverClick (this, e);
}
protected override void RenderAttributes (HtmlTextWriter writer)
{
// we don't want to render the "user" URL, so we either render:
EventHandler serverClick = (EventHandler) Events [serverClickEvent];
if (serverClick != null) {
ClientScriptManager csm;
// a script
PostBackOptions options = GetPostBackOptions ();
csm = Page.ClientScript;
csm.RegisterForEventValidation (options);
Attributes ["href"] = csm.GetPostBackEventReference (options, true);
} else {
string hr = HRef;
if (hr != string.Empty)
#if TARGET_J2EE
// For J2EE portlets we need to genreate a render URL.
HRef = ResolveClientUrl (hr, String.Compare (Target, "_blank", StringComparison.InvariantCultureIgnoreCase) != 0);
#else
HRef = ResolveClientUrl (hr);
#endif
}
base.RenderAttributes (writer);
// but we never set back the href attribute after the rendering
// nor is the property available after rendering
Attributes.Remove ("href");
}
protected virtual void RaisePostBackEvent (string eventArgument)
{
ValidateEvent (UniqueID, eventArgument);
if (CausesValidation)
Page.Validate (ValidationGroup);
OnServerClick (EventArgs.Empty);
}
PostBackOptions GetPostBackOptions ()
{
Page page = Page;
PostBackOptions options = new PostBackOptions (this);
options.ValidationGroup = null;
options.ActionUrl = null;
options.Argument = String.Empty;
options.RequiresJavaScriptProtocol = true;
options.ClientSubmit = true;
options.PerformValidation = CausesValidation && page != null && page.AreValidatorsUplevel (ValidationGroup);
if (options.PerformValidation)
options.ValidationGroup = ValidationGroup;
return options;
}
void IPostBackEventHandler.RaisePostBackEvent (string eventArgument)
{
RaisePostBackEvent (eventArgument);
}
[WebSysDescription("")]
[WebCategory("Action")]
public event EventHandler ServerClick {
add { Events.AddHandler (serverClickEvent, value); }
remove { Events.RemoveHandler (serverClickEvent, value); }
}
}
}

View File

@ -0,0 +1,132 @@
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//
// System.Web.UI.HtmlControls.HtmlButton
//
// Authors:
// Jackson Harper (jackson@ximian.com)
//
// (C) 2005-2010 Novell, Inc.
using System.ComponentModel;
using System.Security.Permissions;
namespace System.Web.UI.HtmlControls {
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[DefaultEvent("ServerClick")]
[SupportsEventValidation]
public class HtmlButton : HtmlContainerControl, IPostBackEventHandler {
static readonly object ServerClickEvent = new object();
public HtmlButton () : base ("button")
{
}
[DefaultValue(true)]
[WebSysDescription("")]
[WebCategory("Behavior")]
public virtual bool CausesValidation {
get {
return ViewState.GetBool ("CausesValidation", true);
}
set {
ViewState ["CausesValidation"] = value;
}
}
[DefaultValue ("")]
public virtual string ValidationGroup
{
get {
return ViewState.GetString ("ValidationGroup", "");
}
set {
ViewState ["ValidationGroup"] = value;
}
}
void IPostBackEventHandler.RaisePostBackEvent (string eventArgument)
{
RaisePostBackEvent (eventArgument);
}
protected virtual void RaisePostBackEvent (string eventArgument)
{
ValidateEvent (UniqueID, eventArgument);
if (CausesValidation)
Page.Validate (ValidationGroup);
OnServerClick (EventArgs.Empty);
}
protected internal override void OnPreRender (EventArgs e)
{
base.OnPreRender (e);
}
protected virtual void OnServerClick (EventArgs e)
{
EventHandler server_click = (EventHandler) Events [ServerClickEvent];
if (server_click != null)
server_click (this, e);
}
protected override void RenderAttributes (HtmlTextWriter writer)
{
Page page = Page;
if (page != null && Events [ServerClickEvent] != null) {
PostBackOptions options = GetPostBackOptions ();
Attributes ["onclick"] += page.ClientScript.GetPostBackEventReference (options, true);
writer.WriteAttribute ("language", "javascript");
}
base.RenderAttributes (writer);
}
PostBackOptions GetPostBackOptions ()
{
Page page = Page;
PostBackOptions options = new PostBackOptions (this);
options.ValidationGroup = null;
options.ActionUrl = null;
options.Argument = String.Empty;
options.RequiresJavaScriptProtocol = false;
options.ClientSubmit = true;
options.PerformValidation = CausesValidation && page != null && page.AreValidatorsUplevel (ValidationGroup);
if (options.PerformValidation)
options.ValidationGroup = ValidationGroup;
return options;
}
[WebSysDescription("")]
[WebCategory("Action")]
public event EventHandler ServerClick {
add { Events.AddHandler (ServerClickEvent, value); }
remove { Events.RemoveHandler (ServerClickEvent, value); }
}
}
}

View File

@ -0,0 +1,149 @@
//
// System.Web.UI.HtmlControls.HtmlContainerControl.cs
//
// Authors:
// Bob Smith <bob@thestuff.net>
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// (C) Bob Smith
// (c) 2002 Ximian, Inc. (http://www.ximian.com)
// Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.ComponentModel;
using System.Security.Permissions;
using System.Text;
//LAMESPEC: The dox talk about HttpException but are very ambigious.
//TODO: Check to see if Render really is overridden instead of a LiteralControl being added. It apears that this is the
//case due to testing. Anything inside the block is overwritten by the content of this control, so it doesnt apear
//to do anything with children.
//TODO: If Test.InnerText = Test.InnerHtml without ever assigning anything into InnerHtml, you get this:
// Exception Details: System.Web.HttpException: Cannot get inner content of Message because the contents are not literal.
//[HttpException (0x80004005): Cannot get inner content of Message because the contents are not literal.]
// System.Web.UI.HtmlControls.HtmlContainerControl.get_InnerHtml() +278
// ASP.test3_aspx.AnchorBtn_Click(Object Source, EventArgs E) in \\genfs2\www24\bobsmith11\test3.aspx:6
// System.Web.UI.HtmlControls.HtmlAnchor.OnServerClick(EventArgs e) +108
// System.Web.UI.HtmlControls.HtmlAnchor.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +26
// System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
// System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +149
// System.Web.UI.Page.ProcessRequestMain() +660
namespace System.Web.UI.HtmlControls
{
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public abstract class HtmlContainerControl : HtmlControl
{
protected HtmlContainerControl () : this ("span")
{}
public HtmlContainerControl (string tag) : base(tag)
{}
[HtmlControlPersistable (false)]
[BrowsableAttribute(false)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public virtual string InnerHtml
{
get {
if (Controls.Count == 0)
return String.Empty;
if (Controls.Count == 1) {
Control ctrl = Controls [0];
LiteralControl lc = ctrl as LiteralControl;
if (lc != null)
return lc.Text;
DataBoundLiteralControl dblc = ctrl as DataBoundLiteralControl;
if (dblc != null)
return dblc.Text;
}
throw new HttpException ("There is no literal content!");
}
set {
Controls.Clear ();
Controls.Add (new LiteralControl (value));
if (value == null)
ViewState.Remove ("innerhtml");
else
ViewState ["innerhtml"] = value;
}
}
[HtmlControlPersistable (false)]
[BrowsableAttribute(false)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public virtual string InnerText
{
get {
return HttpUtility.HtmlDecode (InnerHtml);
}
set {
InnerHtml = HttpUtility.HtmlEncode (value);
}
}
protected internal override void Render (HtmlTextWriter writer)
{
RenderBeginTag (writer);
RenderChildren (writer);
RenderEndTag (writer);
}
protected virtual void RenderEndTag (HtmlTextWriter writer)
{
writer.WriteEndTag (TagName);
}
protected override void RenderAttributes (HtmlTextWriter writer)
{
ViewState.Remove ("innerhtml");
base.RenderAttributes (writer);
}
/* we need to override this because our base class
* (HtmlControl) returns an instance of
* EmptyControlCollection. */
protected override ControlCollection CreateControlCollection ()
{
return new ControlCollection (this);
}
protected override void LoadViewState (object savedState)
{
if (savedState != null) {
base.LoadViewState (savedState);
string inner = ViewState ["innerhtml"] as string;
if (inner != null)
InnerHtml = inner;
}
}
}
}

View File

@ -0,0 +1,175 @@
//
// System.Web.UI.HtmlControls.HtmlControl.cs
//
// Author
// Bob Smith <bob@thestuff.net>
//
//
// (C) Bob Smith
// Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Globalization;
using System.Security.Permissions;
namespace System.Web.UI.HtmlControls{
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[ToolboxItem(false)]
[Designer ("System.Web.UI.Design.HtmlIntrinsicControlDesigner, " + Consts.AssemblySystem_Design,
"System.ComponentModel.Design.IDesigner")]
public abstract class HtmlControl : Control, IAttributeAccessor
{
internal string _tagName;
AttributeCollection _attributes;
protected HtmlControl() : this ("span") {}
protected HtmlControl(string tag)
{
_tagName = tag;
}
protected override ControlCollection CreateControlCollection ()
{
return new EmptyControlCollection (this);
}
internal static string AttributeToString(int n){
if (n != -1)return n.ToString(NumberFormatInfo.InvariantInfo);
return null;
}
internal static string AttributeToString(string s){
if (s != null && s.Length != 0) return s;
return null;
}
internal void PreProcessRelativeReference(HtmlTextWriter writer, string attribName){
string attr = Attributes[attribName];
if (attr != null){
if (attr.Length != 0){
try{
attr = ResolveClientUrl(attr);
}
catch (Exception) {
throw new HttpException(attribName + " property had malformed url");
}
writer.WriteAttribute(attribName, attr);
Attributes.Remove(attribName);
}
}
}
/* keep these two methods in sync with the
* IAttributeAccessor iface methods below */
protected virtual string GetAttribute (string name)
{
return Attributes[name];
}
protected virtual void SetAttribute (string name, string value)
{
Attributes[name] = value;
}
string System.Web.UI.IAttributeAccessor.GetAttribute(string name){
return Attributes[name];
}
void System.Web.UI.IAttributeAccessor.SetAttribute(string name, string value){
Attributes[name] = value;
}
protected virtual void RenderBeginTag (HtmlTextWriter writer)
{
writer.WriteBeginTag (TagName);
RenderAttributes (writer);
writer.Write ('>');
}
protected internal override void Render (HtmlTextWriter writer)
{
RenderBeginTag (writer);
}
protected virtual void RenderAttributes(HtmlTextWriter writer){
if (ID != null){
writer.WriteAttribute("id",ClientID);
}
Attributes.Render(writer);
}
[Browsable(false)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public AttributeCollection Attributes {
get {
if (_attributes == null)
_attributes = new AttributeCollection (ViewState);
return _attributes;
}
}
[DefaultValue(false)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[WebSysDescription("")]
[WebCategory("Behavior")]
[TypeConverter (typeof(MinimizableAttributeTypeConverter))]
public bool Disabled {
get {
string disableAttr = Attributes["disabled"] as string;
return (disableAttr != null);
}
set {
if (!value)
Attributes.Remove ("disabled");
else
Attributes["disabled"] = "disabled";
}
}
[Browsable(false)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public CssStyleCollection Style {
get { return Attributes.CssStyle; }
}
[DefaultValue("")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[WebSysDescription("")]
[WebCategory("Appearance")]
public virtual string TagName {
get { return _tagName; }
}
protected override bool ViewStateIgnoresCase {
get {
return true;
}
}
}
}

View File

@ -0,0 +1,22 @@
//
// System.Web.UI.HtmlControls.HtmlControlBuilder
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// (C) 2003 Ximian, Inc (http://www.ximian.com)
//
using System.Web.UI;
namespace System.Web.UI.HtmlControls
{
class HtmlControlBuilder : ControlBuilder
{
public override bool HasBody ()
{
return false;
}
}
}

View File

@ -0,0 +1,49 @@
//
// System.Web.UI.HtmlControls.HtmlEmptyTagControlBuilder.cs
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Security.Permissions;
namespace System.Web.UI.HtmlControls {
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class HtmlEmptyTagControlBuilder : ControlBuilder
{
public HtmlEmptyTagControlBuilder ()
{
}
public override bool HasBody ()
{
return false; // always
}
}
}

View File

@ -0,0 +1,394 @@
//
// System.Web.UI.HtmlControls.HtmlForm.cs
//
// Author:
// Dick Porter <dick@ximian.com>
//
// Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.ComponentModel;
using System.Collections.Specialized;
using System.Security.Permissions;
using System.Web.Util;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Web.SessionState;
namespace System.Web.UI.HtmlControls
{
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class HtmlForm : HtmlContainerControl
{
bool inited;
string _defaultfocus;
string _defaultbutton;
bool submitdisabledcontrols = false;
bool? isUplevel;
public HtmlForm () : base ("form")
{
}
// LAMESPEC: This is undocumented on MSDN, but apparently it does exist on MS.NET.
// See https://bugzilla.novell.com/show_bug.cgi?id=442104
public string Action {
get {
string action = Attributes ["action"];
if (String.IsNullOrEmpty (action))
return String.Empty;
return action;
}
set {
if (String.IsNullOrEmpty (value))
Attributes ["action"] = null;
else
Attributes ["action"] = value;
}
}
[DefaultValue ("")]
public string DefaultButton {
get {
return _defaultbutton ?? String.Empty;
}
set {
_defaultbutton = value;
}
}
[DefaultValue ("")]
public string DefaultFocus {
get {
return _defaultfocus ?? String.Empty;
}
set {
_defaultfocus = value;
}
}
[DefaultValue ("")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public string Enctype {
get {
string enc = Attributes["enctype"];
if (enc == null) {
return (String.Empty);
}
return (enc);
}
set {
if (value == null) {
Attributes.Remove ("enctype");
} else {
Attributes["enctype"] = value;
}
}
}
[DefaultValue ("")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public string Method {
get {
string method = Attributes["method"];
if ((method == null) || (method.Length == 0)) {
return ("post");
}
return (method);
}
set {
if (value == null) {
Attributes.Remove ("method");
} else {
Attributes["method"] = value;
}
}
}
[DefaultValue ("")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public virtual string Name {
get {
return UniqueID;
}
set {
/* why am i here? I do nothing. */
}
}
[DefaultValue (false)]
public virtual bool SubmitDisabledControls {
get {
return submitdisabledcontrols;
}
set {
submitdisabledcontrols = value;
}
}
[DefaultValue ("")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public string Target {
get {
string target = Attributes["target"];
if (target == null) {
return (String.Empty);
}
return (target);
}
set {
if (value == null) {
Attributes.Remove ("target");
} else {
Attributes["target"] = value;
}
}
}
public override string UniqueID {
get {
Control container = NamingContainer;
if (container == Page)
return ID;
return "aspnetForm";
}
}
[MonoTODO ("why override?")]
protected override ControlCollection CreateControlCollection ()
{
return base.CreateControlCollection ();
}
protected internal override void OnInit (EventArgs e)
{
inited = true;
Page page = Page;
if (page != null) {
page.RegisterViewStateHandler ();
page.RegisterForm (this);
}
base.OnInit (e);
}
internal bool DetermineRenderUplevel ()
{
#if TARGET_J2EE
if (HttpContext.Current == null)
return false;
return (
/* From someplace on the web: "JavaScript 1.2
* and later (also known as ECMAScript) has
* built-in support for regular
* expressions" */
((Page.Request.Browser.EcmaScriptVersion.Major == 1
&& Page.Request.Browser.EcmaScriptVersion.Minor >= 2)
|| (Page.Request.Browser.EcmaScriptVersion.Major > 1))
/* document.getElementById, .getAttribute,
* etc, are all DOM level 1. I don't think we
* use anything in level 2.. */
&& Page.Request.Browser.W3CDomVersion.Major >= 1);
#else
if (isUplevel != null)
return (bool) isUplevel;
isUplevel = UplevelHelper.IsUplevel (
System.Web.Configuration.HttpCapabilitiesBase.GetUserAgentForDetection (HttpContext.Current.Request));
return (bool) isUplevel;
#endif
}
protected internal override void OnPreRender (EventArgs e)
{
base.OnPreRender(e);
}
protected override void RenderAttributes (HtmlTextWriter w)
{
/* Need to always render: method, action and id
*/
string action;
string customAction = Attributes ["action"];
Page page = Page;
HttpRequest req = page != null ? page.RequestInternal : null;
#if !TARGET_J2EE
if (String.IsNullOrEmpty (customAction)) {
string file_path = req != null ? req.ClientFilePath : null;
string current_path = req != null ? req.CurrentExecutionFilePath : null;
if (file_path == null)
action = Action;
else if (file_path == current_path) {
// Just the filename will do
action = UrlUtils.GetFile (file_path);
} else {
// Fun. We need to make cookieless sessions work, so no
// absolute paths here.
bool cookieless;
SessionStateSection sec = WebConfigurationManager.GetSection ("system.web/sessionState") as SessionStateSection;
cookieless = sec != null ? sec.Cookieless == HttpCookieMode.UseUri: false;
string appVPath = HttpRuntime.AppDomainAppVirtualPath;
int appVPathLen = appVPath.Length;
if (appVPathLen > 1) {
if (cookieless) {
if (StrUtils.StartsWith (file_path, appVPath, true))
file_path = file_path.Substring (appVPathLen + 1);
} else if (StrUtils.StartsWith (current_path, appVPath, true))
current_path = current_path.Substring (appVPathLen + 1);
}
if (cookieless) {
Uri current_uri = new Uri ("http://host" + current_path);
Uri fp_uri = new Uri ("http://host" + file_path);
action = fp_uri.MakeRelative (current_uri);
} else
action = current_path;
}
} else
action = customAction;
if (req != null)
action += req.QueryStringRaw;
#else
// Allow the page to transform action to a portlet action url
if (String.IsNullOrEmpty (customAction)) {
string queryString = req.QueryStringRaw;
action = CreateActionUrl (VirtualPathUtility.ToAppRelative (req.CurrentExecutionFilePath) +
(string.IsNullOrEmpty (queryString) ? string.Empty : "?" + queryString));
}
else
action = customAction;
#endif
if (req != null) {
XhtmlConformanceSection xhtml = WebConfigurationManager.GetSection ("system.web/xhtmlConformance") as XhtmlConformanceSection;
if (xhtml == null || xhtml.Mode != XhtmlConformanceMode.Strict)
#if NET_4_0
if (RenderingCompatibilityLessThan40)
#endif
// LAMESPEC: MSDN says the 'name' attribute is rendered only in
// Legacy mode, this is not true.
w.WriteAttribute ("name", Name);
}
w.WriteAttribute ("method", Method);
if (String.IsNullOrEmpty (customAction))
w.WriteAttribute ("action", action, true);
/*
* This is a hack that guarantees the ID is set properly for HtmlControl to
* render it later on. As ugly as it is, we use it here because of the way
* the ID, ClientID and UniqueID properties work internally in our Control
* code.
*
* Fixes bug #82596
*/
if (ID == null) {
#pragma warning disable 219
string client = ClientID;
#pragma warning restore 219
}
string submit = page != null ? page.GetSubmitStatements () : null;
if (!String.IsNullOrEmpty (submit)) {
Attributes.Remove ("onsubmit");
w.WriteAttribute ("onsubmit", submit);
}
/* enctype and target should not be written if
* they are empty
*/
string enctype = Enctype;
if (!String.IsNullOrEmpty (enctype))
w.WriteAttribute ("enctype", enctype);
string target = Target;
if (!String.IsNullOrEmpty (target))
w.WriteAttribute ("target", target);
string defaultbutton = DefaultButton;
if (!String.IsNullOrEmpty (defaultbutton)) {
Control c = FindControl (defaultbutton);
if (c == null || !(c is IButtonControl))
throw new InvalidOperationException(String.Format ("The DefaultButton of '{0}' must be the ID of a control of type IButtonControl.",
ID));
if (page != null && DetermineRenderUplevel ()) {
w.WriteAttribute (
"onkeypress",
"javascript:return " + page.WebFormScriptReference + ".WebForm_FireDefaultButton(event, '" + c.ClientID + "')");
}
}
/* Now remove them from the hash so the base
* RenderAttributes can do all the rest
*/
Attributes.Remove ("method");
Attributes.Remove ("enctype");
Attributes.Remove ("target");
base.RenderAttributes (w);
}
protected internal override void RenderChildren (HtmlTextWriter w)
{
Page page = Page;
if (!inited && page != null) {
page.RegisterViewStateHandler ();
page.RegisterForm (this);
}
if (page != null)
page.OnFormRender (w, ClientID);
base.RenderChildren (w);
if (page != null)
page.OnFormPostRender (w, ClientID);
}
/* According to corcompare */
[MonoTODO ("why override?")]
public override void RenderControl (HtmlTextWriter w)
{
base.RenderControl (w);
}
protected internal override void Render (HtmlTextWriter w)
{
base.Render (w);
}
}
}

View File

@ -0,0 +1,67 @@
//
// System.Web.UI.HtmlControls.HtmlGenericControl.cs
//
// Authors:
// Bob Smith <bob@thestuff.net>
// Gonzalo Paniagua (gonzalo@ximian.com)
//
// (C) Bob Smith
// (c) 2002 Ximian, Inc. (http://www.ximian.com)
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.ComponentModel;
using System.Security.Permissions;
namespace System.Web.UI.HtmlControls{
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[ConstructorNeedsTag(true)]
public class HtmlGenericControl : HtmlContainerControl {
public HtmlGenericControl() :
this ("span")
{
}
public HtmlGenericControl (string tag) :
base ()
{
if (tag == null)
tag = "";
_tagName = tag;
}
[DefaultValue("")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[WebSysDescription("")]
[WebCategory("Appearance")]
public new string TagName
{
get { return _tagName; }
set { _tagName = value; }
}
}
}

View File

@ -0,0 +1,241 @@
//
// System.Web.UI.HtmlControls.HtmlHead
//
// Authors:
// Lluis Sanchez Gual (lluis@novell.com)
//
// Copyright (C) 2004-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.ComponentModel;
using System.Collections;
using System.Security.Permissions;
using System.Web.UI.WebControls;
namespace System.Web.UI.HtmlControls
{
// CAS - no InheritanceDemand here as the class is sealed
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[ControlBuilder (typeof(HtmlHeadBuilder))]
public sealed class HtmlHead: HtmlGenericControl, IParserAccessor
{
#if NET_4_0
string descriptionText;
string keywordsText;
HtmlMeta descriptionMeta;
HtmlMeta keywordsMeta;
#endif
string titleText;
HtmlTitle title;
//Hashtable metadata;
StyleSheetBag styleSheet;
public HtmlHead(): base("head") {}
public HtmlHead (string tag) : base (tag)
{
}
protected internal override void OnInit (EventArgs e)
{
base.OnInit (e);
Page page = Page;
if (page == null)
throw new HttpException ("The <head runat=\"server\"> control requires a page.");
//You can only have one <head runat="server"> control on a page.
if(page.Header != null)
throw new HttpException ("You can only have one <head runat=\"server\"> control on a page.");
page.SetHeader (this);
}
protected internal override void RenderChildren (HtmlTextWriter writer)
{
base.RenderChildren (writer);
if (title == null) {
writer.RenderBeginTag (HtmlTextWriterTag.Title);
if (!String.IsNullOrEmpty (titleText))
writer.Write (titleText);
writer.RenderEndTag ();
}
#if NET_4_0
if (descriptionMeta == null && descriptionText != null) {
writer.AddAttribute ("name", "description");
writer.AddAttribute ("content", HttpUtility.HtmlAttributeEncode (descriptionText));
writer.RenderBeginTag (HtmlTextWriterTag.Meta);
writer.RenderEndTag ();
}
if (keywordsMeta == null && keywordsText != null) {
writer.AddAttribute ("name", "keywords");
writer.AddAttribute ("content", HttpUtility.HtmlAttributeEncode (keywordsText));
writer.RenderBeginTag (HtmlTextWriterTag.Meta);
writer.RenderEndTag ();
}
#endif
if (styleSheet != null)
styleSheet.Render (writer);
}
protected internal override void AddedControl (Control control, int index)
{
//You can only have one <title> element within the <head> element.
HtmlTitle t = control as HtmlTitle;
if (t != null) {
if (title != null)
throw new HttpException ("You can only have one <title> element within the <head> element.");
title = t;
}
#if NET_4_0
HtmlMeta meta = control as HtmlMeta;
if (meta != null) {
if (String.Compare ("keywords", meta.Name, StringComparison.OrdinalIgnoreCase) == 0)
keywordsMeta = meta;
else if (String.Compare ("description", meta.Name, StringComparison.OrdinalIgnoreCase) == 0)
descriptionMeta = meta;
}
#endif
base.AddedControl (control, index);
}
protected internal override void RemovedControl (Control control)
{
if (title == control)
title = null;
#if NET_4_0
if (keywordsMeta == control)
keywordsMeta = null;
else if (descriptionMeta == control)
descriptionMeta = null;
#endif
base.RemovedControl (control);
}
#if NET_4_0
public string Description {
get {
if (descriptionMeta != null)
return descriptionMeta.Content;
return descriptionText;
}
set {
if (descriptionMeta != null)
descriptionMeta.Content = value;
else
descriptionText = value;
}
}
public string Keywords {
get {
if (keywordsMeta != null)
return keywordsMeta.Content;
return keywordsText;
}
set {
if (keywordsMeta != null)
keywordsMeta.Content = value;
else
keywordsText = value;
}
}
#endif
public IStyleSheet StyleSheet {
get {
if (styleSheet == null) styleSheet = new StyleSheetBag ();
return styleSheet;
}
}
public string Title {
get {
if (title != null)
return title.Text;
else
return titleText;
}
set {
if (title != null)
title.Text = value;
else
titleText = value;
}
}
}
internal class StyleSheetBag: IStyleSheet
{
ArrayList entries = new ArrayList ();
internal class StyleEntry
{
public Style Style;
public string Selection;
public IUrlResolutionService UrlResolver;
}
public StyleSheetBag ()
{
}
public void CreateStyleRule (Style style, IUrlResolutionService urlResolver, string selection)
{
StyleEntry entry = new StyleEntry ();
entry.Style = style;
entry.UrlResolver = urlResolver;
entry.Selection = selection;
entries.Add (entry);
}
public void RegisterStyle (Style style, IUrlResolutionService urlResolver)
{
for (int n=0; n<entries.Count; n++) {
if (((StyleEntry)entries[n]).Style == style)
return;
}
string name = "aspnet_" + entries.Count;
style.SetRegisteredCssClass (name);
CreateStyleRule (style, urlResolver, "." + name);
}
public void Render (HtmlTextWriter writer)
{
writer.AddAttribute ("type", "text/css", false);
writer.RenderBeginTag (HtmlTextWriterTag.Style);
foreach (StyleEntry entry in entries) {
CssStyleCollection sts = entry.Style.GetStyleAttributes (entry.UrlResolver);
writer.Write ("\n" + entry.Selection + " {" + sts.Value + "}");
}
writer.RenderEndTag ();
}
}
}

View File

@ -0,0 +1,57 @@
//
// System.Web.UI.HtmlControls.HtmlHeadBuilder
//
// Authors:
// Lluis Sanchez Gual (lluis@novell.com)
//
// Copyright (C) 2004-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections;
using System.Globalization;
using System.Security.Permissions;
namespace System.Web.UI.HtmlControls
{
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class HtmlHeadBuilder : ControlBuilder
{
public override bool AllowWhitespaceLiterals ()
{
return false;
}
public override Type GetChildControlType (string tagName, IDictionary attribs)
{
if (String.Compare (tagName, "title", StringComparison.OrdinalIgnoreCase) == 0)
return typeof (HtmlTitle);
if (String.Compare (tagName, "link", StringComparison.OrdinalIgnoreCase) == 0)
return typeof (HtmlLink);
if (String.Compare (tagName, "meta", StringComparison.OrdinalIgnoreCase) == 0)
return typeof (HtmlMeta);
return null;
}
}
}

View File

@ -0,0 +1,209 @@
//
// System.Web.UI.HtmlControls.HtmlImage.cs
//
// Author:
// Dick Porter <dick@ximian.com>
//
// Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.ComponentModel;
using System.Globalization;
using System.Security.Permissions;
using System.Web.Util;
namespace System.Web.UI.HtmlControls
{
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[ControlBuilder (typeof (HtmlEmptyTagControlBuilder))]
public class HtmlImage : HtmlControl
{
public HtmlImage () : base ("img")
{
}
[DefaultValue ("")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[WebSysDescription("")]
[WebCategory("Layout")]
public string Align {
get {
string align = Attributes["align"];
if (align == null) {
return (String.Empty);
}
return (align);
}
set {
if (value == null) {
Attributes.Remove ("align");
} else {
Attributes["align"] = value;
}
}
}
[DefaultValue ("")]
[WebSysDescription("")]
[WebCategory("Appearance")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[Localizable (true)]
public string Alt {
get {
string alt = Attributes["alt"];
if (alt == null) {
return (String.Empty);
}
return (alt);
}
set {
if (value == null) {
Attributes.Remove ("alt");
} else {
Attributes["alt"] = value;
}
}
}
[DefaultValue (0)]
[WebSysDescription("")]
[WebCategory("Appearance")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public int Border {
get {
string border = Attributes["border"];
if (border == null) {
return (-1);
} else {
return (Int32.Parse (border, Helpers.InvariantCulture));
}
}
set {
if (value == -1) {
Attributes.Remove ("border");
} else {
Attributes["border"] = value.ToString ();
}
}
}
[DefaultValue (100)]
[WebSysDescription("")]
[WebCategory("Layout")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public int Height {
get {
string height = Attributes["height"];
if (height == null) {
return (-1);
} else {
return (Int32.Parse (height, Helpers.InvariantCulture));
}
}
set {
if (value == -1) {
Attributes.Remove ("height");
} else {
Attributes["height"] = value.ToString ();
}
}
}
[DefaultValue ("")]
[WebSysDescription("")]
[WebCategory("Behavior")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[UrlProperty]
public string Src {
get {
string src = Attributes["src"];
if (src == null) {
return (String.Empty);
}
return (src);
}
set {
if (value == null) {
Attributes.Remove ("src");
} else {
Attributes["src"] = value;
}
}
}
[DefaultValue (100)]
[WebSysDescription("")]
[WebCategory("Layout")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public int Width {
get {
string width = Attributes["width"];
if (width == null) {
return (-1);
}
else {
return (Int32.Parse (width, Helpers.InvariantCulture));
}
}
set {
if (value == -1) {
Attributes.Remove ("width");
} else {
Attributes["width"] = value.ToString ();
}
}
}
protected override void RenderAttributes (HtmlTextWriter w)
{
PreProcessRelativeReference (w, "src");
/* MS does not seem to render the src attribute if it
* is empty. Firefox, at least, will fetch the current
* page as the src="" if other img attributes exist.
*/
string src = Attributes["src"];
if (src == null || src.Length == 0)
Attributes.Remove ("src");
base.RenderAttributes (w);
/* MS closes the HTML element at the end of
* the attributes too, according to the nunit
* tests
*/
w.Write (" /");
}
}
}

View File

@ -0,0 +1,278 @@
//
// System.Web.UI.HtmlControls.HtmlInputButton.cs
//
// Authors:
// Jackson Harper (jackson@ximian.com)
//
// (C) 2005-2010 Novell, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.ComponentModel;
using System.Globalization;
using System.Reflection;
using System.Security.Permissions;
using System.Web.Util;
namespace System.Web.UI.HtmlControls {
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[DefaultEventAttribute ("ServerClick")]
[SupportsEventValidation]
public class HtmlInputButton : HtmlInputControl, IPostBackEventHandler
{
static readonly object ServerClickEvent = new object();
public HtmlInputButton () : this ("button")
{
}
public HtmlInputButton (string type) : base (type)
{
}
[DefaultValue(true)]
[WebSysDescription("")]
[WebCategory("Behavior")]
public virtual bool CausesValidation {
get {
string flag = Attributes["CausesValidation"];
if (flag == null)
return true;
return Boolean.Parse (flag);
}
set {
Attributes ["CausesValidation"] = value.ToString();
}
}
[DefaultValue ("")]
public virtual string ValidationGroup
{
get {
string group = Attributes["ValidationGroup"];
if (group == null)
return "";
return group;
}
set {
if (value == null)
Attributes.Remove ("ValidationGroup");
else
Attributes["ValidationGroup"] = value;
}
}
void RaisePostBackEventInternal (string eventArgument)
{
ValidateEvent (UniqueID, eventArgument);
if (CausesValidation)
Page.Validate (ValidationGroup);
if (String.Compare (Type, "reset", true, Helpers.InvariantCulture) != 0)
OnServerClick (EventArgs.Empty);
else
ResetForm (FindForm ());
}
HtmlForm FindForm ()
{
Page p = Page;
if (p != null)
return p.Form;
return null;
}
void ResetForm (HtmlForm form)
{
if (form == null || !form.HasControls ())
return;
ResetChildrenValues (form.Controls);
}
void ResetChildrenValues (ControlCollection children)
{
foreach (Control child in children) {
if (child == null)
continue;
if (child.HasControls ())
ResetChildrenValues (child.Controls);
ResetChildValue (child);
}
}
void ResetChildValue (Control child)
{
Type type = child.GetType ();
object[] attributes = type.GetCustomAttributes (false);
if (attributes == null || attributes.Length == 0)
return;
string defaultProperty = null;
DefaultPropertyAttribute defprop;
foreach (object attr in attributes) {
defprop = attr as DefaultPropertyAttribute;
if (defprop == null)
continue;
defaultProperty = defprop.Name;
break;
}
if (defaultProperty == null || defaultProperty.Length == 0)
return;
PropertyInfo pi = null;
try {
pi = type.GetProperty (defaultProperty,
BindingFlags.Instance |
BindingFlags.Public |
BindingFlags.Static |
BindingFlags.IgnoreCase);
} catch (Exception) {
// ignore
}
if (pi == null || !pi.CanWrite)
return;
attributes = pi.GetCustomAttributes (false);
if (attributes == null || attributes.Length == 0)
return;
DefaultValueAttribute defval = null;
object value = null;
foreach (object attr in attributes) {
defval = attr as DefaultValueAttribute;
if (defval == null)
continue;
value = defval.Value;
break;
}
if (value == null || pi.PropertyType != value.GetType ())
return;
try {
pi.SetValue (child, value, null);
} catch (Exception) {
// ignore
}
}
protected virtual void RaisePostBackEvent (string eventArgument)
{
RaisePostBackEventInternal (eventArgument);
}
void IPostBackEventHandler.RaisePostBackEvent (string eventArgument)
{
RaisePostBackEvent (eventArgument);
}
protected internal override void OnPreRender (EventArgs e)
{
base.OnPreRender (e);
if (Events [ServerClickEvent] != null)
Page.RequiresPostBackScript ();
}
protected virtual void OnServerClick (EventArgs e)
{
EventHandler server_click = (EventHandler) Events [ServerClickEvent];
if (server_click != null)
server_click (this, e);
}
protected override void RenderAttributes (HtmlTextWriter writer)
{
CultureInfo inv = Helpers.InvariantCulture;
string input_type = Type;
if (0 != String.Compare (input_type, "reset", true, inv) &&
((0 == String.Compare (input_type, "submit", true, inv)) ||
(0 == String.Compare (input_type, "button", true, inv) && Events [ServerClickEvent] != null))) {
string onclick = String.Empty;
if (Attributes ["onclick"] != null) {
onclick = ClientScriptManager.EnsureEndsWithSemicolon (Attributes ["onclick"] + onclick);
Attributes.Remove ("onclick");
}
Page page = Page;
if (page != null) {
PostBackOptions options = GetPostBackOptions ();
onclick += page.ClientScript.GetPostBackEventReference (options, true);
}
if (onclick.Length > 0) {
bool encode = true;
if (Events [ServerClickEvent] != null)
encode = false; // tests show that this is indeed
// the case...
writer.WriteAttribute ("onclick", onclick, encode);
writer.WriteAttribute ("language", "javascript");
}
}
Attributes.Remove ("CausesValidation");
// LAMESPEC: MS doesn't actually remove this
//attribute. it shows up in the rendered
//output.
// Attributes.Remove("ValidationGroup");
base.RenderAttributes (writer);
}
PostBackOptions GetPostBackOptions ()
{
Page page = Page;
PostBackOptions options = new PostBackOptions (this);
options.ValidationGroup = null;
options.ActionUrl = null;
options.Argument = String.Empty;
options.RequiresJavaScriptProtocol = false;
options.ClientSubmit = (0 != String.Compare (Type, "submit", true, Helpers.InvariantCulture));
options.PerformValidation = CausesValidation && page != null && page.Validators.Count > 0;
if (options.PerformValidation)
options.ValidationGroup = ValidationGroup;
return options;
}
[WebSysDescription("")]
[WebCategory("Action")]
public event EventHandler ServerClick {
add { Events.AddHandler (ServerClickEvent, value); }
remove { Events.RemoveHandler (ServerClickEvent, value); }
}
}
}

View File

@ -0,0 +1,151 @@
//
// System.Web.UI.HtmlControls.HtmlInputCheckBox.cs
//
// Author:
// Dick Porter <dick@ximian.com>
//
// Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.ComponentModel;
using System.Collections.Specialized;
using System.Security.Permissions;
namespace System.Web.UI.HtmlControls
{
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[DefaultEvent ("ServerChange")]
[SupportsEventValidation]
public class HtmlInputCheckBox : HtmlInputControl, IPostBackDataHandler
{
static readonly object EventServerChange = new object ();
public HtmlInputCheckBox () : base ("checkbox")
{
}
[DefaultValue ("")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[WebSysDescription("")]
[WebCategory("Misc")]
[TypeConverter (typeof(MinimizableAttributeTypeConverter))]
public bool Checked {
get {
string check = Attributes["checked"];
if (check == null) {
return (false);
}
return (true);
}
set {
if (value == false) {
Attributes.Remove ("checked");
} else {
Attributes["checked"] = "checked";
}
}
}
[WebSysDescription("")]
[WebCategory("Action")]
public event EventHandler ServerChange {
add {
Events.AddHandler (EventServerChange, value);
}
remove {
Events.RemoveHandler (EventServerChange, value);
}
}
protected override void RenderAttributes (HtmlTextWriter writer)
{
Page page = Page;
if (page != null)
page.ClientScript.RegisterForEventValidation (UniqueID);
base.RenderAttributes (writer);
}
protected internal override void OnPreRender (EventArgs e)
{
base.OnPreRender (e);
Page page = Page;
if (page != null && !Disabled) {
page.RegisterRequiresPostBack (this);
page.RegisterEnabledControl (this);
}
}
protected virtual void OnServerChange (EventArgs e)
{
EventHandler handler = (EventHandler)Events[EventServerChange];
if (handler != null)
handler (this, e);
}
bool LoadPostDataInternal (string postDataKey, NameValueCollection postCollection)
{
string postedValue = postCollection[postDataKey];
bool postedBool = ((postedValue != null) &&
(postedValue.Length > 0));
if (Checked != postedBool) {
Checked = postedBool;
return (true);
}
return (false);
}
void RaisePostDataChangedEventInternal ()
{
OnServerChange (EventArgs.Empty);
}
protected virtual bool LoadPostData (string postDataKey, NameValueCollection postCollection)
{
return LoadPostDataInternal (postDataKey, postCollection);
}
protected virtual void RaisePostDataChangedEvent ()
{
ValidateEvent (UniqueID, String.Empty);
RaisePostDataChangedEventInternal ();
}
bool IPostBackDataHandler.LoadPostData (string postDataKey, NameValueCollection postCollection)
{
return LoadPostData (postDataKey, postCollection);
}
void IPostBackDataHandler.RaisePostDataChangedEvent ()
{
RaisePostDataChangedEvent();
}
}
}

View File

@ -0,0 +1,95 @@
//
// System.Web.UI.HtmlControls.HtmlInputControl.cs
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.ComponentModel;
using System.Security.Permissions;
namespace System.Web.UI.HtmlControls
{
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[ControlBuilder (typeof (HtmlEmptyTagControlBuilder))]
public abstract class HtmlInputControl : HtmlControl
{
protected HtmlInputControl (string type)
: base ("input")
{
if (type == null)
type = String.Empty;
Attributes ["type"] = type;
}
[DefaultValue ("")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[WebSysDescription("")]
[WebCategory("Behavior")]
public virtual string Name {
get { return UniqueID; }
set { ; }
}
[DefaultValue ("")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[WebSysDescription("")]
[WebCategory("Behavior")]
public string Type {
get { return Attributes ["type"]; }
}
[DefaultValue ("")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[WebSysDescription("")]
[WebCategory("Appearance")]
public virtual string Value {
get {
string s = Attributes ["value"];
return (s == null) ? String.Empty : s;
}
set {
if (value == null)
Attributes.Remove ("value");
else
Attributes ["value"] = value;
}
}
protected override void RenderAttributes (HtmlTextWriter writer)
{
if (Attributes ["name"] == null) {
writer.WriteAttribute ("name", Name);
}
base.RenderAttributes (writer);
writer.Write (" /");
}
}
}

View File

@ -0,0 +1,203 @@
//
// System.Web.UI.HtmlControls.HtmlInputFile.cs
//
// Author:
// Dick Porter <dick@ximian.com>
//
// Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections.Specialized;
using System.ComponentModel;
using System.Security.Permissions;
namespace System.Web.UI.HtmlControls
{
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[ValidationProperty ("Value")]
public class HtmlInputFile : HtmlInputControl , IPostBackDataHandler
{
HttpPostedFile posted_file;
public HtmlInputFile () : base ("file")
{
}
[DefaultValue ("")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[WebSysDescription("")]
public string Accept {
get {
string acc = Attributes["accept"];
if (acc == null) {
return (String.Empty);
}
return (acc);
}
set {
if (value == null) {
Attributes.Remove ("accept");
} else {
Attributes["accept"] = value;
}
}
}
[DefaultValue ("")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[WebSysDescription("")]
public int MaxLength {
get {
string maxlen = Attributes["maxlength"];
if (maxlen == null) {
return (-1);
} else {
return (Convert.ToInt32 (maxlen));
}
}
set {
if (value == -1) {
Attributes.Remove ("maxlength");
} else {
Attributes["maxlength"] = value.ToString ();
}
}
}
[DefaultValue ("")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[WebSysDescription("")]
[WebCategory("Misc")]
public HttpPostedFile PostedFile {
get {
return (posted_file);
}
}
[DefaultValue ("-1")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[WebSysDescription("")]
[WebCategory("Appearance")]
public int Size {
get {
string size = Attributes["size"];
if (size == null) {
return (-1);
} else {
return (Convert.ToInt32 (size));
}
}
set {
if (value == -1) {
Attributes.Remove ("size");
} else {
Attributes["size"] = value.ToString ();
}
}
}
[Browsable (false)]
public override string Value {
get {
HttpPostedFile file = PostedFile;
if (file == null)
return string.Empty;
return file.FileName;
}
set {
throw new NotSupportedException ("The value property on HtmlInputFile is not settable.");
}
}
protected internal override void OnPreRender (EventArgs e)
{
base.OnPreRender (e);
Page page = Page;
if (page != null && !Disabled) {
page.RegisterRequiresPostBack (this);
page.RegisterEnabledControl (this);
}
HtmlForm form = (HtmlForm) SearchParentByType (typeof (HtmlForm));
if (form != null && form.Enctype == String.Empty)
form.Enctype = "multipart/form-data";
}
Control SearchParentByType (Type type)
{
Control ctrl = Parent;
while (ctrl != null) {
if (type.IsAssignableFrom (ctrl.GetType ())) {
return ctrl;
}
ctrl = ctrl.Parent;
}
return null;
}
bool LoadPostDataInternal (string postDataKey, NameValueCollection postCollection)
{
Page page = Page;
if (page != null)
posted_file = page.Request.Files [postDataKey];
return (false);
}
void RaisePostDataChangedEventInternal ()
{
/* No events to raise */
}
protected virtual bool LoadPostData (string postDataKey, NameValueCollection postCollection)
{
return LoadPostDataInternal (postDataKey, postCollection);
}
protected virtual void RaisePostDataChangedEvent ()
{
RaisePostDataChangedEventInternal ();
}
bool IPostBackDataHandler.LoadPostData (string postDataKey, NameValueCollection postCollection)
{
return LoadPostData (postDataKey, postCollection);
}
void IPostBackDataHandler.RaisePostDataChangedEvent ()
{
RaisePostDataChangedEvent ();
}
}
}

View File

@ -0,0 +1,119 @@
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//
// System.Web.UI.HtmlControls.HtmlInputHidden.cs
//
// Authors:
// Jackson Harper (jackson@ximian.com)
//
// (C) 2005-2010 Novell, Inc.
using System.ComponentModel;
using System.Collections.Specialized;
using System.Security.Permissions;
namespace System.Web.UI.HtmlControls {
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[DefaultEvent ("ServerChange")]
[SupportsEventValidation]
public class HtmlInputHidden : HtmlInputControl, IPostBackDataHandler {
static readonly object ServerChangeEvent = new object ();
public HtmlInputHidden () : base ("hidden")
{
}
bool LoadPostDataInternal (string postDataKey, NameValueCollection postCollection)
{
string data = postCollection [postDataKey];
if (data != null && data != Value) {
ValidateEvent (postDataKey, String.Empty);
Value = data;
return true;
}
return false;
}
void RaisePostDataChangedEventInternal ()
{
OnServerChange (EventArgs.Empty);
}
protected virtual bool LoadPostData (string postDataKey, NameValueCollection postCollection)
{
return LoadPostDataInternal (postDataKey, postCollection);
}
protected virtual void RaisePostDataChangedEvent ()
{
RaisePostDataChangedEventInternal ();
}
bool IPostBackDataHandler.LoadPostData (string postDataKey,
NameValueCollection postCollection)
{
return LoadPostData (postDataKey, postCollection);
}
void IPostBackDataHandler.RaisePostDataChangedEvent ()
{
RaisePostDataChangedEvent ();
}
protected override void RenderAttributes (HtmlTextWriter writer)
{
Page page = Page;
if (page != null)
page.ClientScript.RegisterForEventValidation (Name);
base.RenderAttributes (writer);
}
protected internal override void OnPreRender (EventArgs e)
{
base.OnPreRender (e);
Page page = Page;
if (page != null && !Disabled) {
page.RegisterRequiresPostBack (this);
page.RegisterEnabledControl (this);
}
}
protected virtual void OnServerChange (EventArgs e)
{
EventHandler handler = (EventHandler) Events [ServerChangeEvent];
if (handler != null)
handler (this, e);
}
[WebSysDescription("")]
[WebCategory("Action")]
public event EventHandler ServerChange {
add { Events.AddHandler (ServerChangeEvent, value); }
remove { Events.RemoveHandler (ServerChangeEvent, value); }
}
}
}

View File

@ -0,0 +1,248 @@
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//
// System.Web.UI.HtmlControls.HtmlInputImage.cs
//
// Authors:
// Jackson Harper (jackson@ximian.com)
//
// (C) 2005-2010 Novell, Inc.
//
// TODO: getting the .x and .y in LoadData doesn't work with mozilla
//
using System.Globalization;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Security.Permissions;
using System.Web.Util;
namespace System.Web.UI.HtmlControls
{
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[DefaultEvent("ServerClick")]
[SupportsEventValidation]
public class HtmlInputImage : HtmlInputControl, IPostBackDataHandler, IPostBackEventHandler
{
static readonly object ServerClickEvent = new object ();
int clicked_x;
int clicked_y;
public HtmlInputImage () : base ("image")
{
}
[DefaultValue(true)]
[WebSysDescription("")]
[WebCategory("Behavior")]
public virtual bool CausesValidation {
get {
return ViewState.GetBool ("CausesValidation", true);
}
set {
ViewState ["CausesValidation"] = value;
}
}
[DefaultValue("")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[WebSysDescription("")]
[WebCategory("Appearance")]
public string Align {
get { return GetAtt ("align"); }
set { SetAtt ("align", value); }
}
[DefaultValue("")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[Localizable (true)]
[WebSysDescription("")]
[WebCategory("Appearance")]
public string Alt {
get { return GetAtt ("alt"); }
set { SetAtt ("alt", value); }
}
[DefaultValue("")]
[WebSysDescription("")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[WebCategory("Appearance")]
[UrlProperty]
public string Src {
get { return GetAtt ("src"); }
set { SetAtt ("src", value); }
}
[DefaultValue("-1")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[WebSysDescription("")]
[WebCategory("Appearance")]
public int Border {
get {
string border = Attributes ["border"];
if (border == null)
return -1;
return Int32.Parse (border, Helpers.InvariantCulture);
}
set {
if (value == -1) {
Attributes.Remove ("border");
return;
}
Attributes ["border"] = value.ToString (Helpers.InvariantCulture);
}
}
bool LoadPostDataInternal (string postDataKey, NameValueCollection postCollection)
{
string x = postCollection [UniqueID + ".x"];
string y = postCollection [UniqueID + ".y"];
if (x != null && x.Length != 0 &&
y != null && y.Length != 0) {
clicked_x = Int32.Parse (x, Helpers.InvariantCulture);
clicked_y = Int32.Parse (y, Helpers.InvariantCulture);
Page.RegisterRequiresRaiseEvent (this);
return true;
}
return false;
}
void RaisePostBackEventInternal (string eventArgument)
{
if (CausesValidation)
Page.Validate (ValidationGroup);
OnServerClick (new ImageClickEventArgs (clicked_x, clicked_y));
}
void RaisePostDataChangedEventInternal ()
{
/* no events to raise */
}
[DefaultValue ("")]
public virtual string ValidationGroup
{
get {
return ViewState.GetString ("ValidationGroup", "");
}
set {
ViewState ["ValidationGroup"] = value;
}
}
protected virtual bool LoadPostData (string postDataKey, NameValueCollection postCollection)
{
return LoadPostDataInternal (postDataKey, postCollection);
}
protected virtual void RaisePostBackEvent (string eventArgument)
{
RaisePostBackEventInternal (eventArgument);
}
protected virtual void RaisePostDataChangedEvent ()
{
ValidateEvent (UniqueID, String.Empty);
RaisePostDataChangedEventInternal ();
}
bool IPostBackDataHandler.LoadPostData (string postDataKey, NameValueCollection postCollection)
{
return LoadPostData (postDataKey, postCollection);
}
void IPostBackDataHandler.RaisePostDataChangedEvent ()
{
RaisePostDataChangedEvent();
}
void IPostBackEventHandler.RaisePostBackEvent (string eventArgument)
{
RaisePostBackEvent (eventArgument);
}
protected internal override void OnPreRender (EventArgs e)
{
base.OnPreRender (e);
Page page = Page;
if (page != null && !Disabled) {
page.RegisterRequiresPostBack (this);
page.RegisterEnabledControl (this);
}
}
protected virtual void OnServerClick (ImageClickEventArgs e)
{
ImageClickEventHandler handler = Events [ServerClickEvent] as ImageClickEventHandler;
if (handler != null)
handler (this, e);
}
protected override void RenderAttributes (HtmlTextWriter writer)
{
Page page = Page;
if (page != null)
page.ClientScript.RegisterForEventValidation (UniqueID);
if (CausesValidation && page != null && page.AreValidatorsUplevel (ValidationGroup)) {
ClientScriptManager csm = page.ClientScript;
Attributes ["onclick"] += csm.GetClientValidationEvent (ValidationGroup);
}
PreProcessRelativeReference (writer,"src");
base.RenderAttributes (writer);
}
void SetAtt (string name, string value)
{
if ((value == null) || (value.Length == 0))
Attributes.Remove (name);
else
Attributes [name] = value;
}
string GetAtt (string name)
{
string res = Attributes [name];
if (res == null)
return String.Empty;
return res;
}
[WebSysDescription("")]
[WebCategory("Action")]
public event ImageClickEventHandler ServerClick {
add { Events.AddHandler (ServerClickEvent, value); }
remove { Events.AddHandler (ServerClickEvent, value); }
}
}
}

View File

@ -0,0 +1,76 @@
//
// System.Web.UI.HtmlControls.HtmlInputPassword.cs
//
// Author:
// Chris Toshok <toshok@ximian.com>
//
// Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.ComponentModel;
using System.Collections.Specialized;
using System.Security.Permissions;
namespace System.Web.UI.HtmlControls
{
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[DefaultEvent ("ServerChange")]
[ValidationProperty ("Value")]
[SupportsEventValidation]
public class HtmlInputPassword : HtmlInputText, IPostBackDataHandler
{
public HtmlInputPassword ()
: base ("password")
{
}
protected override void RenderAttributes (HtmlTextWriter writer)
{
// make sure we don't render the password
Attributes.Remove ("value");
base.RenderAttributes (writer);
}
bool IPostBackDataHandler.LoadPostData (string postDataKey, NameValueCollection postCollection)
{
string s = postCollection [postDataKey];
if (Attributes ["value"] != s) {
Attributes ["value"] = s;
return true;
}
return false;
}
void IPostBackDataHandler.RaisePostDataChangedEvent ()
{
// We registered in the base class
ValidateEvent (UniqueID, String.Empty);
OnServerChange (EventArgs.Empty);
}
}
}

View File

@ -0,0 +1,157 @@
//
// System.Web.UI.HtmlControls.HtmlInputRadioButton.cs
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.ComponentModel;
using System.Collections.Specialized;
using System.Security.Permissions;
namespace System.Web.UI.HtmlControls
{
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[DefaultEvent ("ServerChange")]
[SupportsEventValidation]
public class HtmlInputRadioButton : HtmlInputControl, IPostBackDataHandler
{
static readonly object serverChangeEvent = new object ();
public HtmlInputRadioButton ()
: base ("radio")
{
}
[DefaultValue ("")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[WebSysDescription("")]
[WebCategory("Misc")]
public bool Checked {
get { return (Attributes ["checked"] == "checked"); }
set {
if (value)
Attributes ["checked"] = "checked";
else
Attributes.Remove ("checked");
}
}
public override string Name {
get {
string s = Attributes ["name"];
return (s == null) ? String.Empty : s;
}
set {
if (value == null)
Attributes.Remove ("name");
else
Attributes ["name"] = value;
}
}
public override string Value {
get {
string s = Attributes ["value"];
if (s == null || s.Length == 0) {
s = ID;
if ((s != null) && (s.Length == 0))
s = null;
}
return s;
}
set {
if (value == null)
Attributes.Remove ("value");
else
Attributes ["value"] = value;
}
}
protected internal override void OnPreRender (EventArgs e)
{
base.OnPreRender (e);
Page page = Page;
if (page != null && !Disabled) {
page.RegisterRequiresPostBack (this);
page.RegisterEnabledControl (this);
}
}
protected virtual void OnServerChange (EventArgs e)
{
EventHandler serverChange = (EventHandler) Events [serverChangeEvent];
if (serverChange != null)
serverChange (this, e);
}
protected override void RenderAttributes (HtmlTextWriter writer)
{
Page page = Page;
if (page != null)
page.ClientScript.RegisterForEventValidation (this.UniqueID, Value);
writer.WriteAttribute ("value", Value, true);
Attributes.Remove ("value");
base.RenderAttributes (writer);
}
protected virtual bool LoadPostData (string postDataKey, NameValueCollection postCollection)
{
bool checkedOnClient = postCollection [Name] == Value;
if (Checked == checkedOnClient)
return false;
ValidateEvent (UniqueID, Value);
Checked = checkedOnClient;
return checkedOnClient;
}
protected virtual void RaisePostDataChangedEvent ()
{
OnServerChange (EventArgs.Empty);
}
bool IPostBackDataHandler.LoadPostData (string postDataKey, NameValueCollection postCollection)
{
return LoadPostData (postDataKey, postCollection);
}
void IPostBackDataHandler.RaisePostDataChangedEvent ()
{
RaisePostDataChangedEvent ();
}
[WebSysDescription("")]
[WebCategory("Action")]
public event EventHandler ServerChange {
add { Events.AddHandler (serverChangeEvent, value); }
remove { Events.RemoveHandler (serverChangeEvent, value); }
}
}
}

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