using System.ComponentModel;
using System.ComponentModel.Design;
+using System.Security.Permissions;
namespace System.Web.UI.WebControls {
+ // CAS
+ [AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+ [AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+ // attributes
[DefaultEvent ("Click")]
[DataBindingHandler ("System.Web.UI.Design.TextDataBindingHandler, " + Consts.AssemblySystem_Design)]
[DefaultProperty ("Text")]
#if NET_2_0
[ToolboxDataAttribute ("<{0}:Button runat=\"server\" Text=\"Button\"></{0}:Button>")]
+ [SupportsEventValidation]
#else
[ToolboxDataAttribute ("<{0}:Button runat=server Text=\"Button\"></{0}:Button>")]
#endif
[WebCategory ("Behavior")]
#if NET_2_0
[Themeable (false)]
- public virtual
-#else
- public
#endif
- string CommandArgument {
+ public string CommandArgument {
get {
return ViewState.GetString ("CommandArgument", "");
}
[WebCategory ("Behavior")]
#if NET_2_0
[Themeable (false)]
- public virtual
-#else
- public
#endif
- string CommandName {
+ public string CommandName {
get {
return ViewState.GetString ("CommandName", "");
}
#if NET_2_0
[Themeable (false)]
[DefaultValue ("")]
- [MonoTODO]
[WebSysDescription ("")]
[WebCategoryAttribute ("Behavior")]
public virtual string OnClientClick
{
get {
- throw new NotImplementedException ();
+ return ViewState.GetString ("OnClientClick", "");
}
set {
- throw new NotImplementedException ();
+ ViewState ["OnClientClick"] = value;
}
}
[WebCategory ("Appearance")]
#if NET_2_0
[Localizable (true)]
- public virtual
-#else
- public
#endif
- string Text {
+ public string Text {
get {
return ViewState.GetString ("Text", "");
}
#if NET_2_0
[DefaultValue (true)]
[Themeable (false)]
- [MonoTODO]
[WebSysDescription ("")]
[WebCategoryAttribute ("Behavior")]
public virtual bool UseSubmitBehavior
{
get {
- throw new NotImplementedException ();
+ return ViewState.GetBool ("UseSubmitBehavior", true);
}
set {
- throw new NotImplementedException ();
+ ViewState ["UseSubmitBehavior"] = value;
}
}
#endif
- protected override void AddAttributesToRender (HtmlTextWriter writer)
- {
+ protected override void AddAttributesToRender (HtmlTextWriter writer) {
if (Page != null)
Page.VerifyRenderingInServerForm (this);
+#if NET_2_0
+ writer.AddAttribute (HtmlTextWriterAttribute.Type, UseSubmitBehavior ? "submit" : "button");
+ writer.AddAttribute (HtmlTextWriterAttribute.Name, UniqueID);
+ writer.AddAttribute (HtmlTextWriterAttribute.Value, Text);
+
+ string onclick = OnClientClick;
+ onclick = ClientScriptManager.EnsureEndsWithSemicolon (onclick);
+ if (Attributes ["onclick"] != null) {
+ onclick = ClientScriptManager.EnsureEndsWithSemicolon (onclick + Attributes ["onclick"]);
+ Attributes.Remove ("onclick");
+ }
+
+ if (Page != null) {
+ PostBackOptions options = GetPostBackOptions ();
+ onclick += Page.ClientScript.GetPostBackEventReference (options);
+ }
+
+ if (onclick.Length > 0)
+ writer.AddAttribute (HtmlTextWriterAttribute.Onclick, onclick);
+#else
writer.AddAttribute (HtmlTextWriterAttribute.Type, "submit");
writer.AddAttribute (HtmlTextWriterAttribute.Name, UniqueID);
writer.AddAttribute (HtmlTextWriterAttribute.Value, Text);
if (CausesValidation && Page != null && Page.AreValidatorsUplevel ()) {
+ string onclick = Attributes["onclick"];
+ if (onclick != null) {
+ Attributes.Remove("onclick");
+ int len = onclick.Length;
+ if (len > 0 && onclick[len - 1] != ';')
+ onclick += ";";
+ }
ClientScriptManager csm = new ClientScriptManager (Page);
- writer.AddAttribute (HtmlTextWriterAttribute.Onclick, csm.GetClientValidationEvent ());
+ writer.AddAttribute (HtmlTextWriterAttribute.Onclick, onclick + csm.GetClientValidationEvent ());
writer.AddAttribute ("language", "javascript");
}
+#endif
base.AddAttributesToRender (writer);
}
#if NET_2_0
- [MonoTODO]
- protected virtual PostBackOptions GetPostBackOptions ()
+ protected virtual PostBackOptions GetPostBackOptions ()
{
- throw new NotImplementedException ();
+ PostBackOptions options = new PostBackOptions (this);
+ options.ActionUrl = (PostBackUrl.Length > 0 ? Page.ResolveClientUrl (PostBackUrl) : null);
+ options.ValidationGroup = null;
+ options.Argument = "";
+ options.RequiresJavaScriptProtocol = false;
+ options.ClientSubmit = !UseSubmitBehavior;
+ options.PerformValidation = CausesValidation && Page != null && Page.AreValidatorsUplevel (ValidationGroup);
+ if (options.PerformValidation)
+ options.ValidationGroup = ValidationGroup;
+
+ return options;
}
#endif
[Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
[Themeable (false)]
[UrlProperty("*.aspx")]
- [MonoTODO]
- public string PostBackUrl {
+ public virtual string PostBackUrl {
get {
- throw new NotImplementedException ();
+ return ViewState.GetString ("PostBackUrl", "");
}
set {
- throw new NotImplementedException ();
+ ViewState ["PostBackUrl"] = value;
}
}
[Themeable (false)]
[WebSysDescription ("")]
[WebCategoryAttribute ("Behavior")]
- public string ValidationGroup {
+ public virtual string ValidationGroup {
get {
return ViewState.GetString ("ValidationGroup", "");
}