2 // System.Web.UI.Page.cs
5 // Duncan Mak (duncan@ximian.com)
6 // Gonzalo Paniagua (gonzalo@ximian.com)
7 // Andreas Nahr (ClassDevelopment@A-SoftTech.com)
9 // (C) 2002,2003 Ximian, Inc. (http://www.ximian.com)
10 // (c) 2003 Novell, Inc. (http://www.novell.com)
14 using System.Collections;
15 using System.Collections.Specialized;
16 using System.ComponentModel;
17 using System.ComponentModel.Design;
18 using System.ComponentModel.Design.Serialization;
19 using System.Globalization;
21 using System.Security.Principal;
23 using System.Threading;
25 using System.Web.Caching;
26 using System.Web.SessionState;
27 using System.Web.Util;
29 namespace System.Web.UI
32 [MonoTODO ("FIXME missing the IRootDesigner Attribute")]
33 [DefaultEvent ("Load"), DesignerCategory ("ASPXCodeBehind")]
35 [Designer ("System.Web.UI.Design.ControlDesigner, " + Consts.AssemblySystem_Design, typeof (IDesigner))]
36 [RootDesignerSerializer ("Microsoft.VSDesigner.WebForms.RootCodeDomSerializer, " + Consts.AssemblyMicrosoft_VSDesigner, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design, true)]
37 public class Page : TemplateControl, IHttpHandler
39 private bool _viewState = true;
40 private bool _viewStateMac;
41 private string _errorPage;
42 private bool _isValid;
43 private bool _smartNavigation;
44 private int _transactionMode;
45 private HttpContext _context;
46 private ValidatorCollection _validators;
47 private bool renderingForm;
48 private object _savedViewState;
49 private ArrayList _requiresPostBack;
50 private ArrayList _requiresPostBackCopy;
51 private ArrayList requiresPostDataChanged;
52 private IPostBackEventHandler requiresRaiseEvent;
53 private NameValueCollection secondPostData;
54 private bool requiresPostBackScript;
55 private bool postBackScriptRendered;
56 private Hashtable registeredArrayDeclares;
57 Hashtable clientScriptBlocks;
58 Hashtable startupScriptBlocks;
59 Hashtable hiddenFields;
60 internal Hashtable submitStatements;
62 string viewStateUserKey;
64 [EditorBrowsable (EditorBrowsableState.Never)]
65 protected const string postEventArgumentID = "__EVENTARGUMENT";
66 [EditorBrowsable (EditorBrowsableState.Never)]
67 protected const string postEventSourceID = "__EVENTTARGET";
79 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
81 public HttpApplicationState Application
83 get { return _context.Application; }
86 [EditorBrowsable (EditorBrowsableState.Never)]
87 protected bool AspCompatMode
89 set { throw new NotImplementedException (); }
92 [EditorBrowsable (EditorBrowsableState.Never)]
95 set { Response.BufferOutput = value; }
98 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
102 get { return _context.Cache; }
106 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
107 [Browsable (false), DefaultValue ("")]
108 [WebSysDescription ("Value do override the automatic browser detection and force the page to use the specified browser.")]
109 public string ClientTarget
111 get { throw new NotImplementedException (); }
112 set { throw new NotImplementedException (); }
115 [EditorBrowsable (EditorBrowsableState.Never)]
116 protected int CodePage
118 set { Response.ContentEncoding = Encoding.GetEncoding (value); }
121 [EditorBrowsable (EditorBrowsableState.Never)]
122 protected string ContentType
124 set { Response.ContentType = value; }
127 protected override HttpContext Context
129 get { return _context; }
132 [EditorBrowsable (EditorBrowsableState.Never)]
133 protected string Culture
135 set { Thread.CurrentThread.CurrentCulture = new CultureInfo (value); }
139 public override bool EnableViewState
141 get { return _viewState; }
142 set { _viewState = value; }
145 [EditorBrowsable (EditorBrowsableState.Never)]
146 protected bool EnableViewStateMac
148 get { return _viewStateMac; }
149 set { _viewStateMac = value; }
152 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
153 [Browsable (false), DefaultValue ("")]
154 [WebSysDescription ("The URL of a page used for error redirection.")]
155 public string ErrorPage
157 get { return _errorPage; }
160 if (_context != null)
161 _context.ErrorPage = value;
165 [EditorBrowsable (EditorBrowsableState.Never)]
166 protected ArrayList FileDependencies
169 if (Response != null)
170 Response.AddFileDependencies (value);
175 public override string ID
177 get { return base.ID; }
178 set { base.ID = value; }
181 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
183 public bool IsPostBack
186 return (0 == String.Compare (Request.HttpMethod, "POST", true));
190 [EditorBrowsable (EditorBrowsableState.Never), Browsable (false)]
191 public bool IsReusable {
192 get { return false; }
195 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
199 get { return _isValid; }
202 [EditorBrowsable (EditorBrowsableState.Never)]
204 set { Thread.CurrentThread.CurrentCulture = new CultureInfo (value); }
207 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
209 public HttpRequest Request
211 get { return _context.Request; }
214 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
216 public HttpResponse Response
218 get { return _context.Response; }
221 [EditorBrowsable (EditorBrowsableState.Never)]
222 protected string ResponseEncoding
224 set { Response.ContentEncoding = Encoding.GetEncoding (value); }
227 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
229 public HttpServerUtility Server
232 return Context.Server;
236 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
238 public virtual HttpSessionState Session
241 if (_context.Session == null)
242 throw new HttpException ("Session state can only be used " +
243 "when enableSessionState is set to true, either " +
244 "in a configuration file or in the Page directive.");
246 return _context.Session;
251 public bool SmartNavigation
253 get { return _smartNavigation; }
254 set { _smartNavigation = value; }
257 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
259 public TraceContext Trace
261 get { return Context.Trace; }
264 [EditorBrowsable (EditorBrowsableState.Never)]
265 protected bool TraceEnabled
267 set { Trace.IsEnabled = value; }
270 [EditorBrowsable (EditorBrowsableState.Never)]
271 protected TraceMode TraceModeValue
273 set { Trace.TraceMode = value; }
276 [EditorBrowsable (EditorBrowsableState.Never)]
277 protected int TransactionMode
279 set { _transactionMode = value; }
282 [EditorBrowsable (EditorBrowsableState.Never)]
283 protected string UICulture
285 set { Thread.CurrentThread.CurrentUICulture = new CultureInfo (value); }
288 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
290 public IPrincipal User
292 get { return _context.User; }
295 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
297 public ValidatorCollection Validators
300 if (_validators == null)
301 _validators = new ValidatorCollection ();
306 [MonoTODO ("Use this when encrypting/decrypting ViewState")]
308 public string ViewStateUserKey {
309 get { return viewStateUserKey; }
310 set { viewStateUserKey = value; }
314 public override bool Visible
316 get { return base.Visible; }
317 set { base.Visible = value; }
324 [EditorBrowsable (EditorBrowsableState.Never)]
325 protected IAsyncResult AspCompatBeginProcessRequest (HttpContext context,
329 throw new NotImplementedException ();
332 [EditorBrowsable (EditorBrowsableState.Never)]
333 protected void AspCompatEndProcessRequest (IAsyncResult result)
335 throw new NotImplementedException ();
338 [EditorBrowsable (EditorBrowsableState.Advanced)]
339 protected virtual HtmlTextWriter CreateHtmlTextWriter (TextWriter tw)
341 return new HtmlTextWriter (tw);
344 [EditorBrowsable (EditorBrowsableState.Never)]
345 public void DesignerInitialize ()
347 InitRecursive (null);
350 [EditorBrowsable (EditorBrowsableState.Advanced)]
351 protected virtual NameValueCollection DeterminePostBackMode ()
353 if (_context == null)
356 HttpRequest req = _context.Request;
360 NameValueCollection coll = null;
364 coll = req.QueryString;
367 if (coll == null || coll ["__VIEWSTATE"] == null)
373 [EditorBrowsable (EditorBrowsableState.Advanced)]
374 public string GetPostBackClientEvent (Control control, string argument)
376 return GetPostBackEventReference (control, argument);
379 [EditorBrowsable (EditorBrowsableState.Advanced)]
380 public string GetPostBackClientHyperlink (Control control, string argument)
382 return "javascript:" + GetPostBackEventReference (control, argument);
385 [EditorBrowsable (EditorBrowsableState.Advanced)]
386 public string GetPostBackEventReference (Control control)
388 return GetPostBackEventReference (control, "");
391 [EditorBrowsable (EditorBrowsableState.Advanced)]
392 public string GetPostBackEventReference (Control control, string argument)
394 RequiresPostBackScript ();
395 return String.Format ("__doPostBack('{0}','{1}')", control.UniqueID, argument);
398 internal void RequiresPostBackScript ()
400 requiresPostBackScript = true;
403 [EditorBrowsable (EditorBrowsableState.Never)]
404 public virtual int GetTypeHashCode ()
410 [EditorBrowsable (EditorBrowsableState.Never)]
411 protected virtual void InitOutputCache (int duration,
414 OutputCacheLocation location,
417 HttpCachePolicy cache = _context.Response.Cache;
420 case OutputCacheLocation.Any:
421 cache.SetCacheability (HttpCacheability.Public);
422 cache.SetMaxAge (new TimeSpan (0, 0, duration));
423 cache.SetLastModified (_context.Timestamp);
424 goto case OutputCacheLocation.Server;
425 case OutputCacheLocation.Client:
426 cache.SetCacheability (HttpCacheability.Private);
427 cache.SetMaxAge (new TimeSpan (0, 0, duration));
428 cache.SetLastModified (_context.Timestamp);
430 case OutputCacheLocation.Downstream:
431 cache.SetCacheability (HttpCacheability.Public);
432 cache.SetMaxAge (new TimeSpan (0, 0, duration));
433 cache.SetLastModified (_context.Timestamp);
435 case OutputCacheLocation.Server:
436 if (varyByCustom != null)
437 cache.SetVaryByCustom (varyByCustom);
439 if (varyByParam != null && varyByParam.Length > 0) {
440 string[] prms = varyByParam.Split (';');
441 foreach (string p in prms)
442 cache.VaryByParams [p.Trim ()] = true;
443 cache.VaryByParams.IgnoreParams = false;
445 cache.VaryByParams.IgnoreParams = true;
448 if (varyByHeader != null && varyByHeader.Length > 0) {
449 string[] hdrs = varyByHeader.Split (';');
450 foreach (string h in hdrs)
451 cache.VaryByHeaders [h.Trim ()] = true;
454 cache.SetCacheability (HttpCacheability.Server);
456 case OutputCacheLocation.None:
459 cache.Duration = duration;
460 cache.SetExpires (_context.Timestamp.AddSeconds (duration));
463 [EditorBrowsable (EditorBrowsableState.Advanced)]
464 public bool IsClientScriptBlockRegistered (string key)
466 if (clientScriptBlocks == null)
469 return clientScriptBlocks.ContainsKey (key);
472 [EditorBrowsable (EditorBrowsableState.Advanced)]
473 public bool IsStartupScriptRegistered (string key)
475 if (startupScriptBlocks == null)
478 return startupScriptBlocks.ContainsKey (key);
481 public string MapPath (string virtualPath)
483 return Request.MapPath (virtualPath);
486 private void RenderPostBackScript (HtmlTextWriter writer, string formUniqueID)
488 writer.WriteLine ("<input type=\"hidden\" name=\"{0}\" value=\"\" />", postEventSourceID);
489 writer.WriteLine ("<input type=\"hidden\" name=\"{0}\" value=\"\" />", postEventArgumentID);
491 writer.WriteLine ("<script language=\"javascript\">");
492 writer.WriteLine ("<!--");
493 writer.WriteLine ("\tfunction __doPostBack(eventTarget, eventArgument) {");
494 writer.WriteLine ("\t\tvar theform = document.getElementById ('{0}');", formUniqueID);
495 writer.WriteLine ("\t\ttheform.{0}.value = eventTarget;", postEventSourceID);
496 writer.WriteLine ("\t\ttheform.{0}.value = eventArgument;", postEventArgumentID);
497 writer.WriteLine ("\t\ttheform.submit();");
498 writer.WriteLine ("\t}");
499 writer.WriteLine ("// -->");
500 writer.WriteLine ("</script>");
503 static void WriteScripts (HtmlTextWriter writer, Hashtable scripts)
508 foreach (string key in scripts.Values)
509 writer.WriteLine (key);
512 void WriteHiddenFields (HtmlTextWriter writer)
514 if (hiddenFields == null)
517 foreach (string key in hiddenFields.Keys) {
518 string value = hiddenFields [key] as string;
519 writer.WriteLine ("\n<input type=\"hidden\" name=\"{0}\" value=\"{1}\" />", key, value);
525 internal void OnFormRender (HtmlTextWriter writer, string formUniqueID)
528 throw new HttpException ("Only 1 HtmlForm is allowed per page.");
530 renderingForm = true;
532 WriteHiddenFields (writer);
533 if (requiresPostBackScript) {
534 RenderPostBackScript (writer, formUniqueID);
535 postBackScriptRendered = true;
538 if (handleViewState) {
539 writer.Write ("<input type=\"hidden\" name=\"__VIEWSTATE\" ");
540 writer.WriteLine ("value=\"{0}\" />", GetViewStateString ());
543 WriteScripts (writer, clientScriptBlocks);
546 internal string GetViewStateString ()
548 StringWriter sr = new StringWriter ();
549 LosFormatter fmt = new LosFormatter ();
550 fmt.Serialize (sr, _savedViewState);
551 return sr.GetStringBuilder ().ToString ();
554 internal void OnFormPostRender (HtmlTextWriter writer, string formUniqueID)
556 if (registeredArrayDeclares != null) {
558 writer.WriteLine("<script language=\"javascript\">");
559 writer.WriteLine("<!--");
560 IDictionaryEnumerator arrayEnum = registeredArrayDeclares.GetEnumerator();
561 while (arrayEnum.MoveNext()) {
562 writer.Write("\tvar ");
563 writer.Write(arrayEnum.Key);
564 writer.Write(" = new Array(");
565 IEnumerator arrayListEnum = ((ArrayList) arrayEnum.Value).GetEnumerator();
567 while (arrayListEnum.MoveNext()) {
572 writer.Write(arrayListEnum.Current);
574 writer.WriteLine(");");
576 writer.WriteLine("// -->");
577 writer.WriteLine("</script>");
581 if (!postBackScriptRendered && requiresPostBackScript)
582 RenderPostBackScript (writer, formUniqueID);
584 WriteHiddenFields (writer);
585 WriteScripts (writer, startupScriptBlocks);
586 renderingForm = false;
587 postBackScriptRendered = false;
590 private void ProcessPostData (NameValueCollection data, bool second)
595 if (_requiresPostBackCopy == null && _requiresPostBack != null)
596 _requiresPostBackCopy = (ArrayList) _requiresPostBack.Clone ();
598 Hashtable used = new Hashtable ();
599 foreach (string id in data.AllKeys){
600 if (id == "__VIEWSTATE" || id == postEventSourceID || id == postEventArgumentID)
604 int dot = real_id.IndexOf ('.');
606 real_id = real_id.Substring (0, dot);
608 if (real_id == null || used.ContainsKey (real_id))
611 used.Add (real_id, real_id);
613 Control ctrl = FindControl (real_id);
615 IPostBackDataHandler pbdh = ctrl as IPostBackDataHandler;
616 IPostBackEventHandler pbeh = ctrl as IPostBackEventHandler;
620 RegisterRequiresRaiseEvent (pbeh);
624 if (pbdh.LoadPostData (real_id, data) == true) {
625 if (requiresPostDataChanged == null)
626 requiresPostDataChanged = new ArrayList ();
627 requiresPostDataChanged.Add (pbdh);
628 if (_requiresPostBackCopy != null)
629 _requiresPostBackCopy.Remove (ctrl.UniqueID);
631 } else if (!second) {
632 if (secondPostData == null)
633 secondPostData = new NameValueCollection ();
634 secondPostData.Add (real_id, data [id]);
638 if (_requiresPostBackCopy != null && _requiresPostBackCopy.Count > 0) {
639 string [] handlers = (string []) _requiresPostBackCopy.ToArray (typeof (string));
640 foreach (string id in handlers) {
641 IPostBackDataHandler pbdh = FindControl (id) as IPostBackDataHandler;
645 _requiresPostBackCopy.Remove (id);
646 if (pbdh.LoadPostData (id, data)) {
647 if (requiresPostDataChanged == null)
648 requiresPostDataChanged = new ArrayList ();
650 requiresPostDataChanged.Add (pbdh);
656 [EditorBrowsable (EditorBrowsableState.Never)]
657 public void ProcessRequest (HttpContext context)
660 WireupAutomaticEvents ();
661 //-- Control execution lifecycle in the docs
663 // Save culture information because it can be modified in FrameworkInitialize()
664 CultureInfo culture = Thread.CurrentThread.CurrentCulture;
665 CultureInfo uiculture = Thread.CurrentThread.CurrentUICulture;
666 FrameworkInitialize ();
667 context.ErrorPage = _errorPage;
670 InternalProcessRequest ();
673 UnloadRecursive (true);
675 Thread.CurrentThread.CurrentCulture = culture;
676 Thread.CurrentThread.CurrentUICulture = uiculture;
680 void InternalProcessRequest ()
682 Trace.Write ("aspx.page", "Begin Init");
683 InitRecursive (null);
684 Trace.Write ("aspx.page", "End Init");
686 renderingForm = false;
688 Trace.Write ("aspx.page", "Begin LoadViewState");
689 LoadPageViewState ();
690 Trace.Write ("aspx.page", "End LoadViewState");
691 Trace.Write ("aspx.page", "Begin ProcessPostData");
692 ProcessPostData (DeterminePostBackMode (), false);
693 Trace.Write ("aspx.page", "End ProcessPostData");
698 Trace.Write ("aspx.page", "Begin ProcessPostData Second Try");
699 ProcessPostData (secondPostData, true);
700 Trace.Write ("aspx.page", "End ProcessPostData Second Try");
701 Trace.Write ("aspx.page", "Begin Raise ChangedEvents");
702 RaiseChangedEvents ();
703 Trace.Write ("aspx.page", "End Raise ChangedEvents");
704 Trace.Write ("aspx.page", "Begin Raise PostBackEvent");
705 RaisePostBackEvents ();
706 Trace.Write ("aspx.page", "End Raise PostBackEvent");
708 Trace.Write ("aspx.page", "Begin PreRender");
709 PreRenderRecursiveInternal ();
710 Trace.Write ("aspx.page", "End PreRender");
712 Trace.Write ("aspx.page", "Begin SaveViewState");
713 SavePageViewState ();
714 Trace.Write ("aspx.page", "End SaveViewState");
717 Trace.Write ("aspx.page", "Begin Render");
718 HtmlTextWriter output = new HtmlTextWriter (_context.Response.Output);
719 RenderControl (output);
720 Trace.Write ("aspx.page", "End Render");
722 RenderTrace (output);
726 private void RenderTrace (HtmlTextWriter output)
728 TraceManager manager = HttpRuntime.TraceManager;
730 if (!Trace.IsEnabled && !manager.Enabled)
735 if (Trace.IsEnabled || manager.PageOutput)
736 Trace.Render (output);
739 internal void RaisePostBackEvents ()
741 if (requiresRaiseEvent != null) {
742 RaisePostBackEvent (requiresRaiseEvent, null);
746 NameValueCollection postdata = DeterminePostBackMode ();
747 if (postdata == null)
750 string eventTarget = postdata [postEventSourceID];
751 if (eventTarget == null || eventTarget.Length == 0) {
756 IPostBackEventHandler target = FindControl (eventTarget) as IPostBackEventHandler;
760 string eventArgument = postdata [postEventArgumentID];
761 RaisePostBackEvent (target, eventArgument);
764 internal void RaiseChangedEvents ()
766 if (requiresPostDataChanged == null)
769 foreach (IPostBackDataHandler ipdh in requiresPostDataChanged)
770 ipdh.RaisePostDataChangedEvent ();
772 requiresPostDataChanged = null;
775 [EditorBrowsable (EditorBrowsableState.Advanced)]
776 protected virtual void RaisePostBackEvent (IPostBackEventHandler sourceControl, string eventArgument)
778 sourceControl.RaisePostBackEvent (eventArgument);
781 [EditorBrowsable (EditorBrowsableState.Advanced)]
782 public void RegisterArrayDeclaration (string arrayName, string arrayValue)
784 if (registeredArrayDeclares == null)
785 registeredArrayDeclares = new Hashtable();
787 if (!registeredArrayDeclares.ContainsKey (arrayName))
788 registeredArrayDeclares.Add (arrayName, new ArrayList());
790 ((ArrayList) registeredArrayDeclares[arrayName]).Add(arrayValue);
793 [EditorBrowsable (EditorBrowsableState.Advanced)]
794 public virtual void RegisterClientScriptBlock (string key, string script)
796 if (IsClientScriptBlockRegistered (key))
799 if (clientScriptBlocks == null)
800 clientScriptBlocks = new Hashtable ();
802 clientScriptBlocks.Add (key, script);
805 [EditorBrowsable (EditorBrowsableState.Advanced)]
806 public virtual void RegisterHiddenField (string hiddenFieldName, string hiddenFieldInitialValue)
808 if (hiddenFields == null)
809 hiddenFields = new Hashtable ();
811 if (!hiddenFields.ContainsKey (hiddenFieldName))
812 hiddenFields.Add (hiddenFieldName, hiddenFieldInitialValue);
814 [MonoTODO("Used in HtmlForm")]
815 internal void RegisterClientScriptFile (string a, string b, string c)
817 throw new NotImplementedException ();
822 [EditorBrowsable (EditorBrowsableState.Advanced)]
823 public void RegisterOnSubmitStatement (string key, string script)
825 if (submitStatements == null)
826 submitStatements = new Hashtable ();
828 if (submitStatements.ContainsKey (key))
831 submitStatements.Add (key, script);
834 [EditorBrowsable (EditorBrowsableState.Advanced)]
835 public void RegisterRequiresPostBack (Control control)
837 if (_requiresPostBack == null)
838 _requiresPostBack = new ArrayList ();
840 _requiresPostBack.Add (control.UniqueID);
843 [EditorBrowsable (EditorBrowsableState.Advanced)]
844 public virtual void RegisterRequiresRaiseEvent (IPostBackEventHandler control)
846 requiresRaiseEvent = control;
849 [EditorBrowsable (EditorBrowsableState.Advanced)]
850 public virtual void RegisterStartupScript (string key, string script)
852 if (IsStartupScriptRegistered (key))
855 if (startupScriptBlocks == null)
856 startupScriptBlocks = new Hashtable ();
858 startupScriptBlocks.Add (key, script);
861 [EditorBrowsable (EditorBrowsableState.Advanced)]
862 public void RegisterViewStateHandler ()
864 handleViewState = true;
867 [EditorBrowsable (EditorBrowsableState.Advanced)]
868 protected virtual void SavePageStateToPersistenceMedium (object viewState)
870 _savedViewState = viewState;
873 [EditorBrowsable (EditorBrowsableState.Advanced)]
874 protected virtual object LoadPageStateFromPersistenceMedium ()
876 NameValueCollection postdata = DeterminePostBackMode ();
878 if (postdata == null || (view_state = postdata ["__VIEWSTATE"]) == null)
881 _savedViewState = null;
882 LosFormatter fmt = new LosFormatter ();
885 _savedViewState = fmt.Deserialize (view_state);
886 } catch (Exception e) {
887 throw new HttpException ("Error restoring page viewstate.\n", e);
890 return _savedViewState;
893 internal void LoadPageViewState()
895 object sState = LoadPageStateFromPersistenceMedium ();
896 if (sState != null) {
897 Pair pair = (Pair) sState;
898 LoadViewStateRecursive (pair.First);
899 _requiresPostBack = pair.Second as ArrayList;
903 internal void SavePageViewState ()
905 if (!handleViewState)
908 Pair pair = new Pair ();
909 pair.First = SaveViewStateRecursive ();
910 if (_requiresPostBack != null && _requiresPostBack.Count > 0)
911 pair.Second = _requiresPostBack;
913 if (pair.First == null && pair.Second == null)
916 SavePageStateToPersistenceMedium (pair);
919 public virtual void Validate ()
921 if (_validators == null || _validators.Count == 0){
926 bool all_valid = true;
927 foreach (IValidator v in _validators){
929 if (v.IsValid == false)
937 [EditorBrowsable (EditorBrowsableState.Advanced)]
938 public virtual void VerifyRenderingInServerForm (Control control)
941 throw new HttpException ("Control '" + control.ClientID + " " + control.GetType () +
942 "' must be rendered within a HtmlForm");
948 public string GetWebResourceUrl(Type type, string resourceName)
951 throw new ArgumentNullException ("type");
953 if (resourceName == null || resourceName.Length == 0)
954 throw new ArgumentNullException ("type");
956 return System.Web.Handlers.AssemblyResourceLoader.GetResourceUrl (type, resourceName);
961 internal void PushDataItemContext (object o)
963 if (dataItemCtx == null)
964 dataItemCtx = new Stack ();
966 dataItemCtx.Push (o);
969 internal void PopDataItemContext ()
971 if (dataItemCtx == null)
972 throw new InvalidOperationException ();
977 internal object CurrentDataItem {
979 if (dataItemCtx == null)
980 throw new InvalidOperationException ("No data item");
982 return dataItemCtx.Peek ();
986 protected object Eval (string expression)
988 return DataBinder.Eval (CurrentDataItem, expression);
991 protected object Eval (string expression, string format)
993 return DataBinder.Eval (CurrentDataItem, expression, format);
996 protected object XPath (string xpathexpression)
998 return XPathBinder.Eval (CurrentDataItem, xpathexpression);
1001 protected object XPath (string xpathexpression, string format)
1003 return XPathBinder.Eval (CurrentDataItem, xpathexpression, format);
1006 protected IEnumerable XPathSelect (string xpathexpression)
1008 return XPathBinder.Select (CurrentDataItem, xpathexpression);