// This will provide extra information when trace is enabled. Might be too verbose.
#define MONO_TRACE
-using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
+using System.Security.Permissions;
using System.Web;
using System.Web.Util;
#if NET_2_0
namespace System.Web.UI
{
+ // CAS
+ [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+ [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+ // attributes
[DefaultProperty ("ID"), DesignerCategory ("Code"), ToolboxItemFilter ("System.Web.UI", ToolboxItemFilterType.Require)]
[ToolboxItem ("System.Web.UI.Design.WebControlToolboxItem, " + Consts.AssemblySystem_Design)]
[Designer ("System.Web.UI.Design.ControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
string uniqueID;
string _userId;
+ TemplateControl _templateControl;
ControlCollection _controls;
Control _namingContainer;
Page _page;
}
}
+ string _appRelativeTemplateSourceDirectory = "~/";
+
[EditorBrowsable (EditorBrowsableState.Advanced)]
[Browsable (false)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public string AppRelativeTemplateSourceDirectory
{
- get {
- throw new NotImplementedException ();
- }
+ get { return _appRelativeTemplateSourceDirectory; }
[EditorBrowsable (EditorBrowsableState.Never)]
- set {
- throw new NotImplementedException ();
- }
+ set { _appRelativeTemplateSourceDirectory = value; }
}
#endif
public Control BindingContainer {
get {
Control container = NamingContainer;
- if ((container.stateMask & BINDING_CONTAINER) == 0)
+ if (container != null && (container.stateMask & BINDING_CONTAINER) == 0)
container = container.BindingContainer;
return container;
}
string client = UniqueID;
if (client != null)
- client = client.Replace (':', '_');
-
+ client = client.Replace (':', ClientIDSeparator);
+
return client;
}
}
#if NET_2_0
- protected char ClientIDSeparator
+ protected char ClientIDSeparator
+#else
+ internal protected char ClientIDSeparator
+#endif
{
get {
- throw new NotImplementedException ();
+ return '_';
}
}
-#endif
+
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[Browsable (false)]
}
#if NET_2_0
+ [MonoTODO ("revisit once we have a real design strategy")]
protected internal bool DesignMode
{
- get {
- throw new NotImplementedException ();
- }
+ get { return false; }
}
#endif
protected char IdSeparator
{
get {
- throw new NotImplementedException ();
+ return '$';
}
}
protected internal bool IsViewStateEnabled
{
get {
- throw new NotImplementedException ();
+ if (Page == null)
+ return false;
+
+ for (Control control = this; control != null; control = control.Parent)
+ if (!control.EnableViewState)
+ return false;
+
+ return true;
}
}
protected bool LoadViewStateByID
{
get {
- throw new NotImplementedException ();
+ return false;
}
}
#endif
public TemplateControl TemplateControl
{
get {
- throw new NotImplementedException ();
+ return _templateControl;
}
[EditorBrowsable (EditorBrowsableState.Never)]
set {
- throw new NotImplementedException ();
+ _templateControl = value;
}
}
#endif
protected bool ChildControlsCreated {
get { return ((stateMask & CHILD_CONTROLS_CREATED) != 0); }
set {
- if (value == false && (stateMask & CHILD_CONTROLS_CREATED) != 0)
- Controls.Clear();
+ if (value == false && (stateMask & CHILD_CONTROLS_CREATED) != 0) {
+ if (_controls != null)
+ _controls.Clear();
+ }
SetMask (CHILD_CONTROLS_CREATED, value);
}
if (!HasControls ())
return;
- foreach (Control c in Controls)
+ foreach (Control c in _controls)
c.NullifyUniqueID ();
}
}
#if NET_2_0
+ [MonoTODO]
[EditorBrowsable (EditorBrowsableState.Advanced)]
public virtual void ApplyStyleSheetSkin (Page page)
{
- throw new NotImplementedException ();
+ if (!EnableTheming) /* this enough? */
+ return;
+
+ /* apply the style sheet skin here */
+ if (page.StyleSheetPageTheme != null) {
+ ControlSkin cs = page.StyleSheetPageTheme.GetControlSkin (GetType(), SkinID);
+ if (cs != null)
+ cs.ApplySkin (this);
+ }
}
#endif
protected bool IsLiteralContent()
{
- if (HasControls () && Controls.Count == 1 && (Controls [0] is LiteralControl))
+ if (HasControls () && _controls.Count == 1 && (_controls [0] is LiteralControl))
return true;
return false;
return null;
Control result = null;
- foreach (Control c in Controls) {
+ foreach (Control c in _controls) {
if (String.Compare (id, c._userId, true) == 0) {
if (result != null && result != c) {
throw new HttpException ("1 Found more than one control with ID '" + id + "'");
{
if (_renderMethodDelegate != null) {
_renderMethodDelegate (writer, this);
- } else if (HasControls ()) {
- int len = Controls.Count;
+ } else if (_controls != null) {
+ int len = _controls.Count;
for (int i = 0; i < len; i++) {
- Control c = Controls [i];
+ Control c = _controls [i];
#if NET_2_0
if (c.Adapter != null)
c.RenderControl (writer, c.Adapter);
if (!HasControls ())
return;
- int len = Controls.Count;
+ int len = _controls.Count;
for (int i = 0; i < len; i++) {
- Control c = Controls [i];
+ Control c = _controls [i];
c.DataBind ();
}
}
HttpContext ctx = Context;
TraceContext trace = (ctx != null) ? ctx.Trace : null;
int pos = 0;
- if (trace.IsEnabled)
+ if ((trace != null) && trace.IsEnabled)
pos = ctx.Response.GetOutputByteCount ();
Render(writer);
- if (trace.IsEnabled) {
+ if ((trace != null) && trace.IsEnabled) {
int size = ctx.Response.GetOutputByteCount () - pos;
trace.SaveSize (this, size >= 0 ? size : 0);
}
HttpResponse resp = Context.Response;
return resp.ApplyAppPathModifier (UrlUtils.Combine (ts, relativeUrl));
}
+
+
+#if NET_2_0
+ public
+#else
+ internal
+#endif
+ string ResolveClientUrl (string relativeUrl)
+ {
+ if (relativeUrl == null)
+ throw new ArgumentNullException ("relativeUrl");
+
+ if (relativeUrl == "")
+ return "";
+
+ if (relativeUrl [0] == '#')
+ return relativeUrl;
+
+ string ts = TemplateSourceDirectory;
+ if (ts == "" || !UrlUtils.IsRelativeUrl (relativeUrl))
+ return relativeUrl;
+
+ HttpResponse resp = Context.Response;
+ string absoluteUrl = resp.ApplyAppPathModifier (UrlUtils.Combine (ts, relativeUrl));
+ if (absoluteUrl.StartsWith (ts + "/"))
+ return absoluteUrl.Substring (ts.Length + 1);
+ return absoluteUrl;
+ }
internal bool HasRenderMethodDelegate () {
return _renderMethodDelegate != null;
#endif
OnLoad (EventArgs.Empty);
if (HasControls ()) {
- int len = Controls.Count;
+ int len = _controls.Count;
for (int i=0;i<len;i++)
{
- Control c = Controls[i];
+ Control c = _controls[i];
c.LoadRecursive ();
}
}
}
#endif
if (HasControls ()) {
- int len = Controls.Count;
+ int len = _controls.Count;
for (int i=0;i<len;i++)
{
- Control c = Controls[i];
+ Control c = _controls[i];
c.UnloadRecursive (dispose);
}
}
if (!HasControls ())
return;
- int len = Controls.Count;
+ int len = _controls.Count;
for (int i=0;i<len;i++)
{
- Control c = Controls[i];
+ Control c = _controls[i];
c.PreRenderRecursiveInternal ();
}
#if MONO_TRACE
trace.Write ("control", String.Format ("InitRecursive {0} {1}", _userId, type_name));
}
#endif
-
if (HasControls ()) {
if ((stateMask & IS_NAMING_CONTAINER) != 0)
namingContainer = this;
namingContainer.AutoID)
namingContainer._userId = namingContainer.GetDefaultName () + "b";
- int len = Controls.Count;
+ int len = _controls.Count;
for (int i=0;i<len;i++)
{
- Control c = Controls[i];
+ Control c = _controls[i];
c._page = Page;
c._namingContainer = namingContainer;
if (namingContainer != null && c._userId == null && c.AutoID)
stateMask |= INITING;
#if NET_2_0
+ ApplyTheme ();
+
if (Adapter != null)
Adapter.OnInit (EventArgs.Empty);
else
int idx = -1;
if (HasControls ())
{
- int len = Controls.Count;
+ int len = _controls.Count;
for (int i=0;i<len;i++)
{
- Control ctrl = Controls[i];
+ Control ctrl = _controls[i];
object ctrlState = ctrl.SaveViewStateRecursive ();
idx++;
if (ctrlState == null)
#endif
stateMask |= VIEWSTATE_LOADED;
}
+
+#if NET_2_0
+ internal ControlSkin controlSkin;
+
+ internal void ApplyTheme ()
+ {
+#if MONO_TRACE
+ TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
+ string type_name = null;
+ if (trace != null) {
+ type_name = GetType ().Name;
+ trace.Write ("control", String.Format ("ApplyThemeRecursive {0} {1}", _userId, type_name));
+ }
+#endif
+ if (Page.PageTheme != null && EnableTheming) {
+ ControlSkin controlSkin = Page.PageTheme.GetControlSkin (GetType (), SkinID);
+ if (controlSkin != null)
+ controlSkin.ApplySkin (this);
+ }
+
+#if MONO_TRACE
+ if (trace != null)
+ trace.Write ("control", String.Format ("End ApplyThemeRecursive {0} {1}", _userId, type_name));
+#endif
+ }
+#endif
internal bool AutoID
{
#if NET_2_0
string skinId = string.Empty;
+ bool _enableTheming = true;
[Browsable (false)]
[Themeable (false)]
[DefaultValue (true)]
public virtual bool EnableTheming
{
- get { return (stateMask & ENABLE_THEMING) != 0; }
- set { SetMask (ENABLE_THEMING, value); }
+ get
+ {
+ if ((stateMask & ENABLE_THEMING) != 0)
+ return _enableTheming;
+
+ if (_parent != null)
+ return _parent.EnableTheming;
+
+ return true;
+ }
+ set
+ {
+ SetMask (ENABLE_THEMING, true);
+ _enableTheming = value;
+ }
}
[Browsable (false)]
get { return skinId; }
set { skinId = value; }
}
-
- /* This shouldnt be in 2.0, and I can't find it in 1.1
- * either, so leaving alone for now.
- */
- protected string GetWebResourceUrl (string resourceName)
- {
- return Page.ClientScript.GetWebResourceUrl (GetType(), resourceName);
- }
-
- string IUrlResolutionService.ResolveClientUrl (string url)
- {
- throw new NotImplementedException ();
- }
ControlBuilder IControlBuilderAccessor.ControlBuilder {
get {throw new NotImplementedException (); }