using System.ComponentModel;
using System.Collections.Specialized;
+using System.Security.Permissions;
+using System.Web.Util;
+using System.Web.UI.WebControls;
namespace System.Web.UI.HtmlControls
{
+ // CAS
+ [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+ [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class HtmlForm : HtmlContainerControl
{
+ bool inited;
+
public HtmlForm () : base ("form")
{
}
#if NET_2_0
+ string defaultbutton = "";
[DefaultValue ("")]
- [MonoTODO]
public string DefaultButton
{
get {
- throw new NotImplementedException ();
+ return defaultbutton;
}
set {
- throw new NotImplementedException ();
+ defaultbutton = (value == null ? "" : value);
}
}
+ string defaultfocus = "";
[DefaultValue ("")]
- [MonoTODO]
public string DefaultFocus
{
get {
- throw new NotImplementedException ();
+ return defaultfocus;
}
set {
- throw new NotImplementedException ();
+ defaultfocus = (value == null ? "" : value);
}
}
#endif
get {
string method = Attributes["method"];
- if (method == null) {
+ if ((method == null) || (method.Length == 0)) {
return ("post");
}
[DefaultValue ("")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
-#if NET_2_0
- public virtual
-#else
- public
-#endif
- string Name
+ public virtual string Name
{
get {
- string name = Attributes["name"];
-
- if (name == null) {
- return (UniqueID);
- }
-
- return (name);
+ return UniqueID;
}
set {
- if (value == null) {
- Attributes.Remove ("name");
- } else {
- Attributes["name"] = value;
- }
+ /* why am i here? I do nothing. */
}
}
#if NET_2_0
+ bool submitdisabledcontrols = false;
[DefaultValue (false)]
- [MonoTODO]
public virtual bool SubmitDisabledControls
{
get {
- throw new NotImplementedException ();
+ return submitdisabledcontrols;
}
set {
- throw new NotImplementedException ();
+ submitdisabledcontrols = value;
}
}
#endif
}
}
-#if NET_2_0
- public override
-#else
- // New in NET1.1 sp1
- public new
-#endif
- string UniqueID
- {
+ public override string UniqueID {
get {
return base.UniqueID;
}
}
#if NET_2_0
- [MonoTODO]
+ [MonoTODO ("why override?")]
protected override ControlCollection CreateControlCollection ()
{
return base.CreateControlCollection ();
#endif
override void OnInit (EventArgs e)
{
+ inited = true;
Page.RegisterViewStateHandler ();
+#if NET_2_0
+ Page.RegisterForm (this);
+#endif
+
base.OnInit (e);
}
#if NET_2_0
- [MonoTODO("Probably something about validators here")]
+ internal bool DetermineRenderUplevel ()
+ {
+ /* this bit is c&p'ed from BaseValidator.DetermineRenderUplevel */
+ try {
+ if (Page != null && Page.Request != null)
+ 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);
+ }
+ catch {
+ /* this can happen with a fake Page in nunit
+ * tests, since Page.Context == null */
+ ;
+ }
+
+ return false;
+ }
+
protected internal override void OnPreRender (EventArgs e)
{
base.OnPreRender(e);
* and id
*/
- string action = Page.Request.FilePath;
- string query = Page.Request.QueryStringRaw;
- if (query != null && query.Length > 0) {
- action += "?" + query;
+ string action;
+ string file_path = Page.Request.FilePath;
+ string current_path = Page.Request.CurrentExecutionFilePath;
+ 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.
+ Uri current_uri = new Uri ("http://host" + current_path);
+ Uri fp_uri = new Uri ("http://host" + file_path);
+ action = fp_uri.MakeRelative (current_uri);
}
-
+
+ action += Page.Request.QueryStringRaw;
+
w.WriteAttribute ("name", Name);
+
w.WriteAttribute ("method", Method);
w.WriteAttribute ("action", action);
if (target != null && target != "") {
w.WriteAttribute ("target", target);
}
-
+
+#if NET_2_0
+ string defaultbutton = DefaultButton;
+ if (defaultbutton != null && 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));
+ }
+#endif
+
/* Now remove them from the hash so the base
* RenderAttributes can do all the rest
*/
- Attributes.Remove ("name");
Attributes.Remove ("method");
Attributes.Remove ("enctype");
Attributes.Remove ("target");
#endif
override void RenderChildren (HtmlTextWriter w)
{
+ if (!inited) {
+ Page.RegisterViewStateHandler ();
+#if NET_2_0
+ Page.RegisterForm (this);
+#endif
+ }
Page.OnFormRender (w, ClientID);
base.RenderChildren (w);
Page.OnFormPostRender (w, ClientID);
#if NET_2_0
/* According to corcompare */
- [MonoTODO]
+ [MonoTODO ("why override?")]
public override void RenderControl (HtmlTextWriter w)
{
base.RenderControl (w);