Page.cs 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581
  1. //
  2. // System.Web.UI.Page.cs
  3. //
  4. // Authors:
  5. // Duncan Mak ([email protected])
  6. // Gonzalo Paniagua ([email protected])
  7. // Andreas Nahr ([email protected])
  8. //
  9. // (C) 2002,2003 Ximian, Inc. (http://www.ximian.com)
  10. // Copyright (C) 2003,2005 Novell, Inc (http://www.novell.com)
  11. //
  12. // Permission is hereby granted, free of charge, to any person obtaining
  13. // a copy of this software and associated documentation files (the
  14. // "Software"), to deal in the Software without restriction, including
  15. // without limitation the rights to use, copy, modify, merge, publish,
  16. // distribute, sublicense, and/or sell copies of the Software, and to
  17. // permit persons to whom the Software is furnished to do so, subject to
  18. // the following conditions:
  19. //
  20. // The above copyright notice and this permission notice shall be
  21. // included in all copies or substantial portions of the Software.
  22. //
  23. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  27. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  28. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  29. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  30. //
  31. using System;
  32. using System.Collections;
  33. using System.Collections.Specialized;
  34. using System.ComponentModel;
  35. using System.ComponentModel.Design;
  36. using System.ComponentModel.Design.Serialization;
  37. using System.Globalization;
  38. using System.IO;
  39. using System.Security.Cryptography;
  40. using System.Security.Permissions;
  41. using System.Security.Principal;
  42. using System.Text;
  43. using System.Threading;
  44. using System.Web;
  45. using System.Web.Caching;
  46. using System.Web.Configuration;
  47. using System.Web.SessionState;
  48. using System.Web.Util;
  49. using System.Web.UI.HtmlControls;
  50. using System.Web.UI.WebControls;
  51. #if NET_2_0
  52. using System.Web.UI.Adapters;
  53. using System.Collections.Generic;
  54. using System.Reflection;
  55. #endif
  56. namespace System.Web.UI
  57. {
  58. // CAS
  59. [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  60. [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  61. #if !NET_2_0
  62. [RootDesignerSerializer ("Microsoft.VSDesigner.WebForms.RootCodeDomSerializer, " + Consts.AssemblyMicrosoft_VSDesigner, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design, true)]
  63. #endif
  64. [DefaultEvent ("Load"), DesignerCategory ("ASPXCodeBehind")]
  65. [ToolboxItem (false)]
  66. #if NET_2_0
  67. [Designer ("Microsoft.VisualStudio.Web.WebForms.WebFormDesigner, " + Consts.AssemblyMicrosoft_VisualStudio_Web, typeof (IRootDesigner))]
  68. #else
  69. [Designer ("Microsoft.VSDesigner.WebForms.WebFormDesigner, " + Consts.AssemblyMicrosoft_VSDesigner, typeof (IRootDesigner))]
  70. #endif
  71. public partial class Page : TemplateControl, IHttpHandler
  72. {
  73. static string machineKeyConfigPath = "system.web/machineKey";
  74. #if NET_2_0
  75. private PageLifeCycle _lifeCycle = PageLifeCycle.Unknown;
  76. private bool _eventValidation = true;
  77. private object [] _savedControlState;
  78. private bool _doLoadPreviousPage;
  79. string _focusedControlID;
  80. bool _hasEnabledControlArray;
  81. #endif
  82. private bool _viewState = true;
  83. private bool _viewStateMac;
  84. private string _errorPage;
  85. private bool is_validated;
  86. private bool _smartNavigation;
  87. private int _transactionMode;
  88. private ValidatorCollection _validators;
  89. private bool renderingForm;
  90. private string _savedViewState;
  91. private ArrayList _requiresPostBack;
  92. private ArrayList _requiresPostBackCopy;
  93. private ArrayList requiresPostDataChanged;
  94. private IPostBackEventHandler requiresRaiseEvent;
  95. private NameValueCollection secondPostData;
  96. private bool requiresPostBackScript;
  97. private bool postBackScriptRendered;
  98. bool handleViewState;
  99. string viewStateUserKey;
  100. NameValueCollection _requestValueCollection;
  101. string clientTarget;
  102. ClientScriptManager scriptManager;
  103. bool allow_load; // true when the Form collection belongs to this page (GetTypeHashCode)
  104. PageStatePersister page_state_persister;
  105. // The initial context
  106. private HttpContext _context;
  107. // cached from the initial context
  108. HttpApplicationState _application;
  109. HttpResponse _response;
  110. HttpRequest _request;
  111. Cache _cache;
  112. HttpSessionState _session;
  113. [EditorBrowsable (EditorBrowsableState.Never)]
  114. #if NET_2_0
  115. public
  116. #else
  117. protected
  118. #endif
  119. const string postEventArgumentID = "__EVENTARGUMENT";
  120. [EditorBrowsable (EditorBrowsableState.Never)]
  121. #if NET_2_0
  122. public
  123. #else
  124. protected
  125. #endif
  126. const string postEventSourceID = "__EVENTTARGET";
  127. #if NET_2_0
  128. const string ScrollPositionXID = "__SCROLLPOSITIONX";
  129. const string ScrollPositionYID = "__SCROLLPOSITIONY";
  130. const string EnabledControlArrayID = "__enabledControlArray";
  131. #endif
  132. #if NET_2_0
  133. internal const string LastFocusID = "__LASTFOCUS";
  134. internal const string CallbackArgumentID = "__CALLBACKARGUMENT";
  135. internal const string CallbackSourceID = "__CALLBACKTARGET";
  136. internal const string PreviousPageID = "__PREVIOUSPAGE";
  137. HtmlHead htmlHeader;
  138. MasterPage masterPage;
  139. string masterPageFile;
  140. Page previousPage;
  141. bool isCrossPagePostBack;
  142. bool isPostBack;
  143. bool isCallback;
  144. ArrayList requireStateControls;
  145. HtmlForm _form;
  146. string _title;
  147. string _theme;
  148. string _styleSheetTheme;
  149. Hashtable items;
  150. bool _maintainScrollPositionOnPostBack;
  151. private bool asyncMode = false;
  152. private TimeSpan asyncTimeout;
  153. private const double DefaultAsyncTimeout = 45.0;
  154. private List<PageAsyncTask> parallelTasks;
  155. private List<PageAsyncTask> serialTasks;
  156. private ViewStateEncryptionMode viewStateEncryptionMode;
  157. private bool controlRegisteredForViewStateEncryption = false;
  158. #endif
  159. #region Constructor
  160. public Page ()
  161. {
  162. scriptManager = new ClientScriptManager (this);
  163. Page = this;
  164. ID = "__Page";
  165. #if NET_2_0
  166. PagesSection ps = WebConfigurationManager.GetSection ("system.web/pages") as PagesSection;
  167. if (ps != null) {
  168. asyncTimeout = ps.AsyncTimeout;
  169. viewStateEncryptionMode = ps.ViewStateEncryptionMode;
  170. } else {
  171. asyncTimeout = TimeSpan.FromSeconds (DefaultAsyncTimeout);
  172. viewStateEncryptionMode = ViewStateEncryptionMode.Auto;
  173. }
  174. #endif
  175. }
  176. #endregion
  177. #region Properties
  178. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  179. [Browsable (false)]
  180. public HttpApplicationState Application {
  181. get { return _application; }
  182. }
  183. [EditorBrowsable (EditorBrowsableState.Never)]
  184. protected bool AspCompatMode {
  185. #if NET_2_0
  186. get { return false; }
  187. #endif
  188. set { throw new NotImplementedException (); }
  189. }
  190. [EditorBrowsable (EditorBrowsableState.Never)]
  191. #if NET_2_0
  192. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  193. [BrowsableAttribute (false)]
  194. public bool Buffer {
  195. get { return Response.BufferOutput; }
  196. set { Response.BufferOutput = value; }
  197. }
  198. #else
  199. protected bool Buffer {
  200. set { Response.BufferOutput = value; }
  201. }
  202. #endif
  203. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  204. [Browsable (false)]
  205. public Cache Cache {
  206. get {
  207. if (_cache == null)
  208. throw new HttpException ("Cache is not available.");
  209. return _cache;
  210. }
  211. }
  212. #if NET_2_0
  213. [EditorBrowsableAttribute (EditorBrowsableState.Advanced)]
  214. #endif
  215. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  216. [Browsable (false), DefaultValue ("")]
  217. [WebSysDescription ("Value do override the automatic browser detection and force the page to use the specified browser.")]
  218. public string ClientTarget {
  219. get { return (clientTarget == null) ? "" : clientTarget; }
  220. set {
  221. clientTarget = value;
  222. if (value == "")
  223. clientTarget = null;
  224. }
  225. }
  226. [EditorBrowsable (EditorBrowsableState.Never)]
  227. #if NET_2_0
  228. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  229. [BrowsableAttribute (false)]
  230. public int CodePage {
  231. get { return Response.ContentEncoding.CodePage; }
  232. set { Response.ContentEncoding = Encoding.GetEncoding (value); }
  233. }
  234. #else
  235. protected int CodePage {
  236. set { Response.ContentEncoding = Encoding.GetEncoding (value); }
  237. }
  238. #endif
  239. [EditorBrowsable (EditorBrowsableState.Never)]
  240. #if NET_2_0
  241. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  242. [BrowsableAttribute (false)]
  243. public string ContentType {
  244. get { return Response.ContentType; }
  245. set { Response.ContentType = value; }
  246. }
  247. #else
  248. protected string ContentType {
  249. set { Response.ContentType = value; }
  250. }
  251. #endif
  252. protected override HttpContext Context {
  253. get {
  254. if (_context == null)
  255. return HttpContext.Current;
  256. return _context;
  257. }
  258. }
  259. #if NET_2_0
  260. [EditorBrowsable (EditorBrowsableState.Advanced)]
  261. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  262. [BrowsableAttribute (false)]
  263. public string Culture {
  264. get { return Thread.CurrentThread.CurrentCulture.Name; }
  265. set { Thread.CurrentThread.CurrentCulture = GetPageCulture (value, Thread.CurrentThread.CurrentCulture); }
  266. }
  267. #else
  268. [EditorBrowsable (EditorBrowsableState.Never)]
  269. protected string Culture {
  270. set { Thread.CurrentThread.CurrentCulture = new CultureInfo (value); }
  271. }
  272. #endif
  273. #if NET_2_0
  274. public virtual bool EnableEventValidation {
  275. get { return _eventValidation; }
  276. set {
  277. if (_lifeCycle > PageLifeCycle.Init)
  278. throw new InvalidOperationException ("The 'EnableEventValidation' property can be set only in the Page_init, the Page directive or in the <pages> configuration section.");
  279. _eventValidation = value;
  280. }
  281. }
  282. internal PageLifeCycle LifeCycle {
  283. get { return _lifeCycle; }
  284. }
  285. #endif
  286. [Browsable (false)]
  287. public override bool EnableViewState {
  288. get { return _viewState; }
  289. set { _viewState = value; }
  290. }
  291. #if NET_2_0
  292. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  293. [BrowsableAttribute (false)]
  294. #endif
  295. [EditorBrowsable (EditorBrowsableState.Never)]
  296. #if NET_2_0
  297. public
  298. #else
  299. protected
  300. #endif
  301. bool EnableViewStateMac {
  302. get { return _viewStateMac; }
  303. set { _viewStateMac = value; }
  304. }
  305. #if NET_1_1
  306. internal bool EnableViewStateMacInternal {
  307. get { return _viewStateMac; }
  308. set { _viewStateMac = value; }
  309. }
  310. #endif
  311. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  312. [Browsable (false), DefaultValue ("")]
  313. [WebSysDescription ("The URL of a page used for error redirection.")]
  314. public string ErrorPage {
  315. get { return _errorPage; }
  316. set {
  317. HttpContext ctx = Context;
  318. _errorPage = value;
  319. if (ctx != null)
  320. ctx.ErrorPage = value;
  321. }
  322. }
  323. #if NET_2_0
  324. [Obsolete]
  325. #endif
  326. [EditorBrowsable (EditorBrowsableState.Never)]
  327. protected ArrayList FileDependencies {
  328. set {
  329. if (Response != null)
  330. Response.AddFileDependencies (value);
  331. }
  332. }
  333. [Browsable (false)]
  334. #if NET_2_0
  335. [EditorBrowsable (EditorBrowsableState.Never)]
  336. #endif
  337. public override string ID {
  338. get { return base.ID; }
  339. set { base.ID = value; }
  340. }
  341. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  342. [Browsable (false)]
  343. public bool IsPostBack {
  344. get {
  345. #if NET_2_0
  346. return isPostBack;
  347. #else
  348. return _requestValueCollection != null && !HttpContext.Current.InTransit;
  349. #endif
  350. }
  351. }
  352. [EditorBrowsable (EditorBrowsableState.Never), Browsable (false)]
  353. public bool IsReusable {
  354. get { return false; }
  355. }
  356. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  357. [Browsable (false)]
  358. public bool IsValid {
  359. get {
  360. if (!is_validated)
  361. throw new HttpException (Locale.GetText ("Page hasn't been validated."));
  362. #if NET_2_0
  363. foreach (IValidator val in Validators)
  364. if (!val.IsValid)
  365. return false;
  366. return true;
  367. #else
  368. return ValidateCollection (_validators);
  369. #endif
  370. }
  371. }
  372. #if NET_2_0
  373. public IDictionary Items {
  374. get {
  375. if (items == null)
  376. items = new Hashtable ();
  377. return items;
  378. }
  379. }
  380. #endif
  381. [EditorBrowsable (EditorBrowsableState.Never)]
  382. #if NET_2_0
  383. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  384. [BrowsableAttribute (false)]
  385. public int LCID {
  386. get { return Thread.CurrentThread.CurrentCulture.LCID; }
  387. set { Thread.CurrentThread.CurrentCulture = new CultureInfo (value); }
  388. }
  389. #else
  390. protected int LCID {
  391. set { Thread.CurrentThread.CurrentCulture = new CultureInfo (value); }
  392. }
  393. #endif
  394. #if NET_2_0
  395. [Browsable (false)]
  396. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  397. public bool MaintainScrollPositionOnPostBack {
  398. get { return _maintainScrollPositionOnPostBack; }
  399. set { _maintainScrollPositionOnPostBack = value; }
  400. }
  401. #endif
  402. #if NET_2_0
  403. public PageAdapter PageAdapter {
  404. get {
  405. return (PageAdapter)Adapter;
  406. }
  407. }
  408. #endif
  409. #if !TARGET_J2EE
  410. internal string theForm {
  411. get {
  412. return "theForm";
  413. }
  414. }
  415. internal bool IsMultiForm {
  416. get { return false; }
  417. }
  418. #endif
  419. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  420. [Browsable (false)]
  421. public HttpRequest Request {
  422. get {
  423. if (_request == null)
  424. throw new HttpException("Request is not available in this context.");
  425. return _request;
  426. }
  427. }
  428. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  429. [Browsable (false)]
  430. public HttpResponse Response {
  431. get {
  432. if (_response == null)
  433. throw new HttpException ("Response is not available in this context.");
  434. return _response;
  435. }
  436. }
  437. [EditorBrowsable (EditorBrowsableState.Never)]
  438. #if NET_2_0
  439. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  440. [BrowsableAttribute (false)]
  441. public string ResponseEncoding {
  442. get { return Response.ContentEncoding.WebName; }
  443. set { Response.ContentEncoding = Encoding.GetEncoding (value); }
  444. }
  445. #else
  446. protected string ResponseEncoding {
  447. set { Response.ContentEncoding = Encoding.GetEncoding (value); }
  448. }
  449. #endif
  450. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  451. [Browsable (false)]
  452. public HttpServerUtility Server {
  453. get { return Context.Server; }
  454. }
  455. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  456. [Browsable (false)]
  457. public virtual HttpSessionState Session {
  458. get {
  459. if (_session != null)
  460. return _session;
  461. try {
  462. _session = Context.Session;
  463. } catch {
  464. // ignore, should not throw
  465. }
  466. if (_session == null)
  467. throw new HttpException ("Session state can only be used " +
  468. "when enableSessionState is set to true, either " +
  469. "in a configuration file or in the Page directive.");
  470. return _session;
  471. }
  472. }
  473. #if NET_2_0
  474. [FilterableAttribute (false)]
  475. [Obsolete]
  476. #endif
  477. [Browsable (false)]
  478. public bool SmartNavigation {
  479. get { return _smartNavigation; }
  480. set { _smartNavigation = value; }
  481. }
  482. #if NET_2_0
  483. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  484. [Filterable (false)]
  485. [Browsable (false)]
  486. public virtual string StyleSheetTheme {
  487. get { return _styleSheetTheme; }
  488. set { _styleSheetTheme = value; }
  489. }
  490. [Browsable (false)]
  491. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  492. public virtual string Theme {
  493. get { return _theme; }
  494. set { _theme = value; }
  495. }
  496. void InitializeStyleSheet ()
  497. {
  498. if (_styleSheetTheme == null) {
  499. PagesSection ps = WebConfigurationManager.GetSection ("system.web/pages") as PagesSection;
  500. if (ps != null)
  501. _styleSheetTheme = ps.StyleSheetTheme;
  502. }
  503. if (_styleSheetTheme != null && _styleSheetTheme != "")
  504. _styleSheetPageTheme = ThemeDirectoryCompiler.GetCompiledInstance (_styleSheetTheme, Context);
  505. }
  506. void InitializeTheme ()
  507. {
  508. if (_theme == null) {
  509. PagesSection ps = WebConfigurationManager.GetSection ("system.web/pages") as PagesSection;
  510. if (ps != null)
  511. _theme = ps.Theme;
  512. }
  513. if (_theme != null && _theme != "") {
  514. _pageTheme = ThemeDirectoryCompiler.GetCompiledInstance (_theme, Context);
  515. _pageTheme.SetPage (this);
  516. }
  517. }
  518. #endif
  519. #if NET_2_0
  520. [Localizable (true)]
  521. [Bindable (true)]
  522. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  523. public string Title {
  524. get {
  525. if (_title == null) {
  526. if (htmlHeader != null)
  527. return htmlHeader.Title;
  528. return String.Empty;
  529. }
  530. return _title;
  531. }
  532. set {
  533. if (htmlHeader != null)
  534. htmlHeader.Title = value;
  535. else
  536. _title = value;
  537. }
  538. }
  539. #endif
  540. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  541. [Browsable (false)]
  542. public TraceContext Trace {
  543. get { return Context.Trace; }
  544. }
  545. [EditorBrowsable (EditorBrowsableState.Never)]
  546. #if NET_2_0
  547. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  548. [BrowsableAttribute (false)]
  549. public bool TraceEnabled {
  550. get { return Trace.IsEnabled; }
  551. set { Trace.IsEnabled = value; }
  552. }
  553. #else
  554. protected bool TraceEnabled {
  555. set { Trace.IsEnabled = value; }
  556. }
  557. #endif
  558. [EditorBrowsable (EditorBrowsableState.Never)]
  559. #if NET_2_0
  560. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  561. [BrowsableAttribute (false)]
  562. public TraceMode TraceModeValue {
  563. get { return Trace.TraceMode; }
  564. set { Trace.TraceMode = value; }
  565. }
  566. #else
  567. protected TraceMode TraceModeValue {
  568. set { Trace.TraceMode = value; }
  569. }
  570. #endif
  571. [EditorBrowsable (EditorBrowsableState.Never)]
  572. protected int TransactionMode {
  573. #if NET_2_0
  574. get { return _transactionMode; }
  575. #endif
  576. set { _transactionMode = value; }
  577. }
  578. #if !NET_2_0
  579. //
  580. // This method is here just to remove the warning about "_transactionMode" not being
  581. // used. We probably will use it internally at some point.
  582. //
  583. internal int GetTransactionMode ()
  584. {
  585. return _transactionMode;
  586. }
  587. #endif
  588. #if NET_2_0
  589. [EditorBrowsable (EditorBrowsableState.Advanced)]
  590. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  591. [BrowsableAttribute (false)]
  592. public string UICulture {
  593. get { return Thread.CurrentThread.CurrentUICulture.Name; }
  594. set { Thread.CurrentThread.CurrentUICulture = GetPageCulture (value, Thread.CurrentThread.CurrentUICulture); }
  595. }
  596. #else
  597. [EditorBrowsable (EditorBrowsableState.Never)]
  598. protected string UICulture {
  599. set { Thread.CurrentThread.CurrentUICulture = new CultureInfo (value); }
  600. }
  601. #endif
  602. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  603. [Browsable (false)]
  604. public IPrincipal User {
  605. get { return Context.User; }
  606. }
  607. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  608. [Browsable (false)]
  609. public ValidatorCollection Validators {
  610. get {
  611. if (_validators == null)
  612. _validators = new ValidatorCollection ();
  613. return _validators;
  614. }
  615. }
  616. [MonoTODO ("Use this when encrypting/decrypting ViewState")]
  617. [Browsable (false)]
  618. public string ViewStateUserKey {
  619. get { return viewStateUserKey; }
  620. set { viewStateUserKey = value; }
  621. }
  622. [Browsable (false)]
  623. public override bool Visible {
  624. get { return base.Visible; }
  625. set { base.Visible = value; }
  626. }
  627. #endregion
  628. #region Methods
  629. #if NET_2_0
  630. CultureInfo GetPageCulture (string culture, CultureInfo deflt)
  631. {
  632. if (culture == null)
  633. return deflt;
  634. CultureInfo ret = null;
  635. if (culture.StartsWith ("auto", StringComparison.InvariantCultureIgnoreCase)) {
  636. #if TARGET_J2EE
  637. if (Context.IsPortletRequest)
  638. return deflt;
  639. #endif
  640. string[] languages = Request.UserLanguages;
  641. try {
  642. if (languages != null && languages.Length > 0)
  643. ret = CultureInfo.CreateSpecificCulture (languages[0]);
  644. } catch {
  645. }
  646. if (ret == null)
  647. ret = deflt;
  648. } else
  649. ret = CultureInfo.CreateSpecificCulture (culture);
  650. return ret;
  651. }
  652. #endif
  653. [EditorBrowsable (EditorBrowsableState.Never)]
  654. protected IAsyncResult AspCompatBeginProcessRequest (HttpContext context,
  655. AsyncCallback cb,
  656. object extraData)
  657. {
  658. throw new NotImplementedException ();
  659. }
  660. [EditorBrowsable (EditorBrowsableState.Never)]
  661. protected void AspCompatEndProcessRequest (IAsyncResult result)
  662. {
  663. throw new NotImplementedException ();
  664. }
  665. [EditorBrowsable (EditorBrowsableState.Advanced)]
  666. protected virtual HtmlTextWriter CreateHtmlTextWriter (TextWriter tw)
  667. {
  668. return new HtmlTextWriter (tw);
  669. }
  670. [EditorBrowsable (EditorBrowsableState.Never)]
  671. public void DesignerInitialize ()
  672. {
  673. InitRecursive (null);
  674. }
  675. [EditorBrowsable (EditorBrowsableState.Advanced)]
  676. protected virtual NameValueCollection DeterminePostBackMode ()
  677. {
  678. HttpRequest req = Request;
  679. if (req == null)
  680. return null;
  681. NameValueCollection coll = null;
  682. if (0 == String.Compare (Request.HttpMethod, "POST", true, CultureInfo.InvariantCulture))
  683. coll = req.Form;
  684. #if TARGET_J2EE
  685. else if (IsPortletRender && req.Form ["__VIEWSTATE"] != null)
  686. coll = req.Form;
  687. #endif
  688. else
  689. coll = req.QueryString;
  690. WebROCollection c = (WebROCollection) coll;
  691. allow_load = !c.GotID;
  692. if (allow_load)
  693. c.ID = GetTypeHashCode ();
  694. else
  695. allow_load = (c.ID == GetTypeHashCode ());
  696. if (coll != null && coll ["__VIEWSTATE"] == null && coll ["__EVENTTARGET"] == null)
  697. return null;
  698. return coll;
  699. }
  700. #if NET_2_0
  701. public override Control FindControl (string id) {
  702. if (id == ID)
  703. return this;
  704. else
  705. return base.FindControl (id);
  706. }
  707. #endif
  708. #if NET_2_0
  709. [Obsolete]
  710. #endif
  711. [EditorBrowsable (EditorBrowsableState.Advanced)]
  712. public string GetPostBackClientEvent (Control control, string argument)
  713. {
  714. return scriptManager.GetPostBackEventReference (control, argument);
  715. }
  716. #if NET_2_0
  717. [Obsolete]
  718. #endif
  719. [EditorBrowsable (EditorBrowsableState.Advanced)]
  720. public string GetPostBackClientHyperlink (Control control, string argument)
  721. {
  722. return scriptManager.GetPostBackClientHyperlink (control, argument);
  723. }
  724. #if NET_2_0
  725. [Obsolete]
  726. #endif
  727. [EditorBrowsable (EditorBrowsableState.Advanced)]
  728. public string GetPostBackEventReference (Control control)
  729. {
  730. return scriptManager.GetPostBackEventReference (control, "");
  731. }
  732. #if NET_2_0
  733. [Obsolete]
  734. #endif
  735. [EditorBrowsable (EditorBrowsableState.Advanced)]
  736. public string GetPostBackEventReference (Control control, string argument)
  737. {
  738. return scriptManager.GetPostBackEventReference (control, argument);
  739. }
  740. internal void RequiresPostBackScript ()
  741. {
  742. #if NET_2_0
  743. if (requiresPostBackScript)
  744. return;
  745. ClientScript.RegisterHiddenField (postEventSourceID, String.Empty);
  746. ClientScript.RegisterHiddenField (postEventArgumentID, String.Empty);
  747. #endif
  748. requiresPostBackScript = true;
  749. }
  750. [EditorBrowsable (EditorBrowsableState.Never)]
  751. public virtual int GetTypeHashCode ()
  752. {
  753. return 0;
  754. }
  755. #if NET_2_0
  756. [MonoTODO("The following properties of OutputCacheParameters are silently ignored: CacheProfile, NoStore, SqlDependency")]
  757. protected internal virtual void InitOutputCache(OutputCacheParameters cacheSettings)
  758. {
  759. if (cacheSettings.Enabled)
  760. InitOutputCache(cacheSettings.Duration,
  761. cacheSettings.VaryByHeader,
  762. cacheSettings.VaryByCustom,
  763. cacheSettings.Location,
  764. cacheSettings.VaryByParam);
  765. }
  766. #endif
  767. [EditorBrowsable (EditorBrowsableState.Never)]
  768. protected virtual void InitOutputCache (int duration,
  769. string varyByHeader,
  770. string varyByCustom,
  771. OutputCacheLocation location,
  772. string varyByParam)
  773. {
  774. HttpCachePolicy cache = Response.Cache;
  775. bool set_vary = false;
  776. HttpContext ctx = Context;
  777. DateTime timestamp = ctx != null ? ctx.Timestamp : DateTime.Now;
  778. switch (location) {
  779. case OutputCacheLocation.Any:
  780. cache.SetCacheability (HttpCacheability.Public);
  781. cache.SetMaxAge (new TimeSpan (0, 0, duration));
  782. cache.SetLastModified (timestamp);
  783. set_vary = true;
  784. break;
  785. case OutputCacheLocation.Client:
  786. cache.SetCacheability (HttpCacheability.Private);
  787. cache.SetMaxAge (new TimeSpan (0, 0, duration));
  788. cache.SetLastModified (timestamp);
  789. break;
  790. case OutputCacheLocation.Downstream:
  791. cache.SetCacheability (HttpCacheability.Public);
  792. cache.SetMaxAge (new TimeSpan (0, 0, duration));
  793. cache.SetLastModified (timestamp);
  794. break;
  795. case OutputCacheLocation.Server:
  796. cache.SetCacheability (HttpCacheability.Server);
  797. set_vary = true;
  798. break;
  799. case OutputCacheLocation.None:
  800. break;
  801. }
  802. if (set_vary) {
  803. if (varyByCustom != null)
  804. cache.SetVaryByCustom (varyByCustom);
  805. if (varyByParam != null && varyByParam.Length > 0) {
  806. string[] prms = varyByParam.Split (';');
  807. foreach (string p in prms)
  808. cache.VaryByParams [p.Trim ()] = true;
  809. cache.VaryByParams.IgnoreParams = false;
  810. } else {
  811. cache.VaryByParams.IgnoreParams = true;
  812. }
  813. if (varyByHeader != null && varyByHeader.Length > 0) {
  814. string[] hdrs = varyByHeader.Split (';');
  815. foreach (string h in hdrs)
  816. cache.VaryByHeaders [h.Trim ()] = true;
  817. }
  818. }
  819. cache.Duration = duration;
  820. cache.SetExpires (timestamp.AddSeconds (duration));
  821. }
  822. #if NET_2_0
  823. [Obsolete]
  824. #else
  825. [EditorBrowsable (EditorBrowsableState.Advanced)]
  826. #endif
  827. public bool IsClientScriptBlockRegistered (string key)
  828. {
  829. return scriptManager.IsClientScriptBlockRegistered (key);
  830. }
  831. #if NET_2_0
  832. [Obsolete]
  833. #else
  834. [EditorBrowsable (EditorBrowsableState.Advanced)]
  835. #endif
  836. public bool IsStartupScriptRegistered (string key)
  837. {
  838. return scriptManager.IsStartupScriptRegistered (key);
  839. }
  840. public string MapPath (string virtualPath)
  841. {
  842. return Request.MapPath (virtualPath);
  843. }
  844. #if NET_2_0
  845. protected internal override void Render (HtmlTextWriter writer) {
  846. if (MaintainScrollPositionOnPostBack) {
  847. ClientScript.RegisterWebFormClientScript ();
  848. ClientScript.RegisterHiddenField (ScrollPositionXID, Request [ScrollPositionXID]);
  849. ClientScript.RegisterHiddenField (ScrollPositionYID, Request [ScrollPositionYID]);
  850. string webForm = IsMultiForm ? theForm + "." : null;
  851. StringBuilder script = new StringBuilder ();
  852. script.AppendLine ("<script type=\"text/javascript\">");
  853. script.AppendLine (ClientScriptManager.SCRIPT_BLOCK_START);
  854. script.AppendLine (theForm + ".oldSubmit = " + theForm + ".submit;");
  855. script.AppendLine (theForm + ".submit = function () { " + webForm + "WebForm_SaveScrollPositionSubmit(); }");
  856. script.AppendLine (theForm + ".oldOnSubmit = " + theForm + ".onsubmit;");
  857. script.AppendLine (theForm + ".onsubmit = function () { " + webForm + "WebForm_SaveScrollPositionOnSubmit(); }");
  858. if (IsPostBack) {
  859. script.AppendLine (theForm + ".oldOnLoad = window.onload;");
  860. script.AppendLine ("window.onload = function () { " + webForm + "WebForm_RestoreScrollPosition (); };");
  861. }
  862. script.AppendLine (ClientScriptManager.SCRIPT_BLOCK_END);
  863. script.AppendLine ("</script>");
  864. ClientScript.RegisterStartupScript (typeof (Page), "MaintainScrollPositionOnPostBackStartup", script.ToString());
  865. }
  866. base.Render (writer);
  867. }
  868. #endif
  869. private void RenderPostBackScript (HtmlTextWriter writer, string formUniqueID)
  870. {
  871. #if ONLY_1_1
  872. writer.WriteLine ("<input type=\"hidden\" name=\"{0}\" value=\"\" />", postEventSourceID);
  873. writer.WriteLine ("<input type=\"hidden\" name=\"{0}\" value=\"\" />", postEventArgumentID);
  874. #endif
  875. writer.WriteLine ();
  876. ClientScriptManager.WriteBeginScriptBlock (writer);
  877. #if ONLY_1_1
  878. RenderClientScriptFormDeclaration (writer, formUniqueID);
  879. #endif
  880. if (IsMultiForm) {
  881. writer.WriteLine ("{0}._form = {0};", theForm);
  882. writer.Write (theForm + ".");
  883. } else {
  884. writer.WriteLine ("window._form = {0};", theForm);
  885. }
  886. writer.WriteLine ("__doPostBack = function (eventTarget, eventArgument) {");
  887. #if NET_2_0
  888. writer.WriteLine ("\tif(this._form.onsubmit && this._form.onsubmit() == false) return;");
  889. #else
  890. writer.WriteLine ("\tif(document.ValidatorOnSubmit && !ValidatorOnSubmit()) return;");
  891. #endif
  892. writer.WriteLine ("\tthis._form.{0}.value = eventTarget;", postEventSourceID);
  893. writer.WriteLine ("\tthis._form.{0}.value = eventArgument;", postEventArgumentID);
  894. writer.WriteLine ("\tthis._form.submit();");
  895. writer.WriteLine ("}");
  896. ClientScriptManager.WriteEndScriptBlock (writer);
  897. }
  898. void RenderClientScriptFormDeclaration (HtmlTextWriter writer, string formUniqueID)
  899. {
  900. writer.WriteLine ("\tvar {0};\n\tif (document.getElementById) {{ {0} = document.getElementById ('{1}'); }}", theForm, formUniqueID);
  901. writer.WriteLine ("\telse {{ {0} = document.{1}; }}", theForm, formUniqueID);
  902. writer.WriteLine ("\t{0}._instanceVariableName = '{0}';", theForm);
  903. #if TARGET_J2EE
  904. string serverUrl = Context.ServletResponse.encodeURL (Request.RawUrl);
  905. writer.WriteLine ("\t{0}.serverURL = {1};", theForm, ClientScriptManager.GetScriptLiteral (serverUrl));
  906. writer.WriteLine ("\twindow.TARGET_J2EE = true;");
  907. writer.WriteLine ("\twindow.IsMultiForm = {0};", IsMultiForm ? "true" : "false");
  908. #endif
  909. }
  910. internal void OnFormRender (HtmlTextWriter writer, string formUniqueID)
  911. {
  912. if (renderingForm)
  913. throw new HttpException ("Only 1 HtmlForm is allowed per page.");
  914. renderingForm = true;
  915. writer.WriteLine ();
  916. #if NET_2_0
  917. ClientScriptManager.WriteBeginScriptBlock (writer);
  918. RenderClientScriptFormDeclaration (writer, formUniqueID);
  919. ClientScriptManager.WriteEndScriptBlock (writer);
  920. #endif
  921. if (handleViewState)
  922. scriptManager.RegisterHiddenField ("__VIEWSTATE", _savedViewState);
  923. scriptManager.WriteHiddenFields (writer);
  924. if (requiresPostBackScript) {
  925. RenderPostBackScript (writer, formUniqueID);
  926. postBackScriptRendered = true;
  927. }
  928. #if NET_2_0
  929. scriptManager.WriteWebFormClientScript (writer);
  930. #endif
  931. scriptManager.WriteClientScriptBlocks (writer);
  932. }
  933. internal IStateFormatter GetFormatter ()
  934. {
  935. return new ObjectStateFormatter (this);
  936. }
  937. internal string GetSavedViewState ()
  938. {
  939. return _savedViewState;
  940. }
  941. internal void OnFormPostRender (HtmlTextWriter writer, string formUniqueID)
  942. {
  943. #if NET_2_0
  944. scriptManager.SaveEventValidationState ();
  945. scriptManager.WriteExpandoAttributes (writer);
  946. #endif
  947. scriptManager.WriteHiddenFields (writer);
  948. if (!postBackScriptRendered && requiresPostBackScript)
  949. RenderPostBackScript (writer, formUniqueID);
  950. #if NET_2_0
  951. scriptManager.WriteWebFormClientScript (writer);
  952. #endif
  953. scriptManager.WriteArrayDeclares (writer);
  954. scriptManager.WriteStartupScriptBlocks (writer);
  955. renderingForm = false;
  956. postBackScriptRendered = false;
  957. }
  958. private void ProcessPostData (NameValueCollection data, bool second)
  959. {
  960. NameValueCollection requestValues = _requestValueCollection == null ?
  961. new NameValueCollection () :
  962. _requestValueCollection;
  963. if (data != null && data.Count > 0) {
  964. Hashtable used = new Hashtable ();
  965. foreach (string id in data.AllKeys){
  966. if (id == "__VIEWSTATE" || id == postEventSourceID || id == postEventArgumentID ||
  967. id == ClientScriptManager.EventStateFieldName)
  968. continue;
  969. if (used.ContainsKey (id))
  970. continue;
  971. used.Add (id, id);
  972. Control ctrl = FindControl (id);
  973. if (ctrl != null){
  974. IPostBackDataHandler pbdh = ctrl as IPostBackDataHandler;
  975. IPostBackEventHandler pbeh = ctrl as IPostBackEventHandler;
  976. if (pbdh == null) {
  977. if (pbeh != null)
  978. RegisterRequiresRaiseEvent (pbeh);
  979. continue;
  980. }
  981. if (pbdh.LoadPostData (id, requestValues) == true) {
  982. if (requiresPostDataChanged == null)
  983. requiresPostDataChanged = new ArrayList ();
  984. requiresPostDataChanged.Add (pbdh);
  985. }
  986. if (_requiresPostBackCopy != null)
  987. _requiresPostBackCopy.Remove (id);
  988. } else if (!second) {
  989. if (secondPostData == null)
  990. secondPostData = new NameValueCollection ();
  991. secondPostData.Add (id, data [id]);
  992. }
  993. }
  994. }
  995. ArrayList list1 = null;
  996. if (_requiresPostBackCopy != null && _requiresPostBackCopy.Count > 0) {
  997. string [] handlers = (string []) _requiresPostBackCopy.ToArray (typeof (string));
  998. foreach (string id in handlers) {
  999. IPostBackDataHandler pbdh = FindControl (id) as IPostBackDataHandler;
  1000. if (pbdh != null) {
  1001. _requiresPostBackCopy.Remove (id);
  1002. if (pbdh.LoadPostData (id, requestValues)) {
  1003. if (requiresPostDataChanged == null)
  1004. requiresPostDataChanged = new ArrayList ();
  1005. requiresPostDataChanged.Add (pbdh);
  1006. }
  1007. } else if (!second) {
  1008. if (list1 == null)
  1009. list1 = new ArrayList ();
  1010. list1.Add (id);
  1011. }
  1012. }
  1013. }
  1014. _requiresPostBackCopy = second ? null : list1;
  1015. if (second)
  1016. secondPostData = null;
  1017. }
  1018. [EditorBrowsable (EditorBrowsableState.Never)]
  1019. #if NET_2_0
  1020. public virtual void ProcessRequest (HttpContext context)
  1021. #else
  1022. public void ProcessRequest (HttpContext context)
  1023. #endif
  1024. {
  1025. #if NET_2_0
  1026. _lifeCycle = PageLifeCycle.Unknown;
  1027. #endif
  1028. _context = context;
  1029. _application = context.Application;
  1030. _response = context.Response;
  1031. _request = context.Request;
  1032. _cache = context.Cache;
  1033. if (clientTarget != null)
  1034. Request.ClientTarget = clientTarget;
  1035. WireupAutomaticEvents ();
  1036. //-- Control execution lifecycle in the docs
  1037. // Save culture information because it can be modified in FrameworkInitialize()
  1038. CultureInfo culture = Thread.CurrentThread.CurrentCulture;
  1039. CultureInfo uiculture = Thread.CurrentThread.CurrentUICulture;
  1040. FrameworkInitialize ();
  1041. context.ErrorPage = _errorPage;
  1042. try {
  1043. InternalProcessRequest ();
  1044. } catch (ThreadAbortException) {
  1045. // Do nothing, just ignore it by now.
  1046. } catch (Exception e) {
  1047. context.AddError (e); // OnError might access LastError
  1048. OnError (EventArgs.Empty);
  1049. context.ClearError (e);
  1050. // We want to remove that error, as we're rethrowing to stop
  1051. // further processing.
  1052. Trace.Warn ("Unhandled Exception", e.ToString (), e);
  1053. throw;
  1054. } finally {
  1055. try {
  1056. #if NET_2_0
  1057. _lifeCycle = PageLifeCycle.Unload;
  1058. #endif
  1059. RenderTrace ();
  1060. UnloadRecursive (true);
  1061. #if NET_2_0
  1062. _lifeCycle = PageLifeCycle.End;
  1063. #endif
  1064. } catch {}
  1065. if (Thread.CurrentThread.CurrentCulture.Equals (culture) == false)
  1066. Thread.CurrentThread.CurrentCulture = culture;
  1067. if (Thread.CurrentThread.CurrentUICulture.Equals (uiculture) == false)
  1068. Thread.CurrentThread.CurrentUICulture = uiculture;
  1069. }
  1070. }
  1071. #if NET_2_0
  1072. delegate void ProcessRequestDelegate (HttpContext context);
  1073. private sealed class DummyAsyncResult : IAsyncResult
  1074. {
  1075. readonly object state;
  1076. readonly WaitHandle asyncWaitHandle;
  1077. readonly bool completedSynchronously;
  1078. readonly bool isCompleted;
  1079. public DummyAsyncResult (bool isCompleted, bool completedSynchronously, object state)
  1080. {
  1081. this.isCompleted = isCompleted;
  1082. this.completedSynchronously = completedSynchronously;
  1083. this.state = state;
  1084. if (isCompleted) {
  1085. asyncWaitHandle = new ManualResetEvent (true);
  1086. }
  1087. else {
  1088. asyncWaitHandle = new ManualResetEvent (false);
  1089. }
  1090. }
  1091. #region IAsyncResult Members
  1092. public object AsyncState {
  1093. get { return state; }
  1094. }
  1095. public WaitHandle AsyncWaitHandle {
  1096. get { return asyncWaitHandle; }
  1097. }
  1098. public bool CompletedSynchronously {
  1099. get { return completedSynchronously; }
  1100. }
  1101. public bool IsCompleted {
  1102. get { return isCompleted; }
  1103. }
  1104. #endregion
  1105. }
  1106. protected IAsyncResult AsyncPageBeginProcessRequest (HttpContext context, AsyncCallback callback, object extraData)
  1107. {
  1108. ProcessRequest (context);
  1109. DummyAsyncResult asyncResult = new DummyAsyncResult (true, true, extraData);
  1110. if (callback != null) {
  1111. callback (asyncResult);
  1112. }
  1113. return asyncResult;
  1114. }
  1115. protected void AsyncPageEndProcessRequest (IAsyncResult result)
  1116. {
  1117. }
  1118. internal void ProcessCrossPagePostBack (HttpContext context)
  1119. {
  1120. isCrossPagePostBack = true;
  1121. ProcessRequest (context);
  1122. }
  1123. #endif
  1124. void InternalProcessRequest ()
  1125. {
  1126. _requestValueCollection = this.DeterminePostBackMode();
  1127. #if NET_2_0
  1128. HttpContext ctx = Context;
  1129. _lifeCycle = PageLifeCycle.Start;
  1130. // http://msdn2.microsoft.com/en-us/library/ms178141.aspx
  1131. if (_requestValueCollection != null) {
  1132. if (!isCrossPagePostBack && _requestValueCollection [PreviousPageID] != null && _requestValueCollection [PreviousPageID] != Request.FilePath) {
  1133. _doLoadPreviousPage = true;
  1134. }
  1135. else {
  1136. isCallback = _requestValueCollection [CallbackArgumentID] != null;
  1137. // LAMESPEC: on Callback IsPostBack is set to false, but true.
  1138. //isPostBack = !isCallback;
  1139. isPostBack = !ctx.InTransit;
  1140. }
  1141. string lastFocus = _requestValueCollection [LastFocusID];
  1142. if (!String.IsNullOrEmpty (lastFocus)) {
  1143. _focusedControlID = UniqueID2ClientID (lastFocus);
  1144. }
  1145. }
  1146. // if request was transfered from other page - track Prev. Page
  1147. previousPage = ctx.LastPage;
  1148. ctx.LastPage = this;
  1149. _lifeCycle = PageLifeCycle.PreInit;
  1150. OnPreInit (EventArgs.Empty);
  1151. InitializeTheme ();
  1152. ApplyMasterPage ();
  1153. _lifeCycle = PageLifeCycle.Init;
  1154. #endif
  1155. Trace.Write ("aspx.page", "Begin Init");
  1156. InitRecursive (null);
  1157. Trace.Write ("aspx.page", "End Init");
  1158. #if NET_2_0
  1159. _lifeCycle = PageLifeCycle.InitComplete;
  1160. OnInitComplete (EventArgs.Empty);
  1161. #endif
  1162. renderingForm = false;
  1163. #if NET_2_0
  1164. if (IsPostBack || IsCallback) {
  1165. _lifeCycle = PageLifeCycle.PreLoad;
  1166. if (_requestValueCollection != null)
  1167. scriptManager.RestoreEventValidationState (
  1168. _requestValueCollection [ClientScriptManager.EventStateFieldName]);
  1169. #else
  1170. if (IsPostBack) {
  1171. #endif
  1172. Trace.Write ("aspx.page", "Begin LoadViewState");
  1173. LoadPageViewState ();
  1174. Trace.Write ("aspx.page", "End LoadViewState");
  1175. Trace.Write ("aspx.page", "Begin ProcessPostData");
  1176. #if TARGET_J2EE
  1177. if (!IsGetBack)
  1178. #endif
  1179. ProcessPostData (_requestValueCollection, false);
  1180. Trace.Write ("aspx.page", "End ProcessPostData");
  1181. }
  1182. #if NET_2_0
  1183. OnPreLoad (EventArgs.Empty);
  1184. _lifeCycle = PageLifeCycle.Load;
  1185. #endif
  1186. LoadRecursive ();
  1187. #if NET_2_0
  1188. #if TARGET_J2EE
  1189. if (!IsGetBack)
  1190. #endif
  1191. if (IsPostBack || IsCallback) {
  1192. _lifeCycle = PageLifeCycle.ControlEvents;
  1193. #else
  1194. if (IsPostBack) {
  1195. #endif
  1196. Trace.Write ("aspx.page", "Begin ProcessPostData Second Try");
  1197. ProcessPostData (secondPostData, true);
  1198. Trace.Write ("aspx.page", "End ProcessPostData Second Try");
  1199. Trace.Write ("aspx.page", "Begin Raise ChangedEvents");
  1200. RaiseChangedEvents ();
  1201. Trace.Write ("aspx.page", "End Raise ChangedEvents");
  1202. Trace.Write ("aspx.page", "Begin Raise PostBackEvent");
  1203. RaisePostBackEvents ();
  1204. Trace.Write ("aspx.page", "End Raise PostBackEvent");
  1205. }
  1206. #if NET_2_0
  1207. _lifeCycle = PageLifeCycle.LoadComplete;
  1208. OnLoadComplete (EventArgs.Empty);
  1209. if (IsCrossPagePostBack)
  1210. return;
  1211. if (IsCallback) {
  1212. string result = ProcessCallbackData ();
  1213. HtmlTextWriter callbackOutput = new HtmlTextWriter (Response.Output);
  1214. callbackOutput.Write (result);
  1215. callbackOutput.Flush ();
  1216. return;
  1217. }
  1218. _lifeCycle = PageLifeCycle.PreRender;
  1219. #endif
  1220. Trace.Write ("aspx.page", "Begin PreRender");
  1221. PreRenderRecursiveInternal ();
  1222. Trace.Write ("aspx.page", "End PreRender");
  1223. #if NET_2_0
  1224. ExecuteRegisteredAsyncTasks ();
  1225. _lifeCycle = PageLifeCycle.PreRenderComplete;
  1226. OnPreRenderComplete (EventArgs.Empty);
  1227. #endif
  1228. Trace.Write ("aspx.page", "Begin SaveViewState");
  1229. SavePageViewState ();
  1230. Trace.Write ("aspx.page", "End SaveViewState");
  1231. #if NET_2_0
  1232. _lifeCycle = PageLifeCycle.SaveStateComplete;
  1233. OnSaveStateComplete (EventArgs.Empty);
  1234. #if TARGET_J2EE
  1235. if (OnSaveStateCompleteForPortlet ())
  1236. return;
  1237. #endif // TARGET_J2EE
  1238. #endif // NET_2_0
  1239. #if NET_2_0
  1240. _lifeCycle = PageLifeCycle.Render;
  1241. scriptManager.ResetEventValidationState ();
  1242. #endif
  1243. //--
  1244. Trace.Write ("aspx.page", "Begin Render");
  1245. HtmlTextWriter output = new HtmlTextWriter (Response.Output);
  1246. RenderControl (output);
  1247. Trace.Write ("aspx.page", "End Render");
  1248. }
  1249. private void RenderTrace ()
  1250. {
  1251. TraceManager traceManager = HttpRuntime.TraceManager;
  1252. if (Trace.HaveTrace && !Trace.IsEnabled || !Trace.HaveTrace && !traceManager.Enabled)
  1253. return;
  1254. Trace.SaveData ();
  1255. if (!Trace.HaveTrace && traceManager.Enabled && !traceManager.PageOutput)
  1256. return;
  1257. if (!traceManager.LocalOnly || Context.Request.IsLocal) {
  1258. HtmlTextWriter output = new HtmlTextWriter (Response.Output);
  1259. Trace.Render (output);
  1260. }
  1261. }
  1262. #if NET_2_0
  1263. bool CheckForValidationSupport (Control targetControl)
  1264. {
  1265. if (targetControl == null)
  1266. return false;
  1267. Type type = targetControl.GetType ();
  1268. object[] attributes = type.GetCustomAttributes (false);
  1269. foreach (object attr in attributes)
  1270. if (attr is SupportsEventValidationAttribute)
  1271. return true;
  1272. return false;
  1273. }
  1274. #endif
  1275. void RaisePostBackEvents ()
  1276. {
  1277. #if NET_2_0
  1278. Control targetControl;
  1279. #endif
  1280. if (requiresRaiseEvent != null) {
  1281. RaisePostBackEvent (requiresRaiseEvent, null);
  1282. return;
  1283. }
  1284. NameValueCollection postdata = _requestValueCollection;
  1285. if (postdata == null)
  1286. return;
  1287. string eventTarget = postdata [postEventSourceID];
  1288. if (eventTarget == null || eventTarget.Length == 0) {
  1289. Validate ();
  1290. return;
  1291. }
  1292. #if NET_2_0
  1293. targetControl = FindControl (eventTarget);
  1294. IPostBackEventHandler target = targetControl as IPostBackEventHandler;
  1295. #else
  1296. IPostBackEventHandler target = FindControl (eventTarget) as IPostBackEventHandler;
  1297. #endif
  1298. if (target == null)
  1299. return;
  1300. string eventArgument = postdata [postEventArgumentID];
  1301. RaisePostBackEvent (target, eventArgument);
  1302. }
  1303. internal void RaiseChangedEvents ()
  1304. {
  1305. if (requiresPostDataChanged == null)
  1306. return;
  1307. foreach (IPostBackDataHandler ipdh in requiresPostDataChanged)
  1308. ipdh.RaisePostDataChangedEvent ();
  1309. requiresPostDataChanged = null;
  1310. }
  1311. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1312. protected virtual void RaisePostBackEvent (IPostBackEventHandler sourceControl, string eventArgument)
  1313. {
  1314. #if NET_2_0
  1315. Control targetControl = sourceControl as Control;
  1316. if (targetControl != null && CheckForValidationSupport (targetControl))
  1317. scriptManager.ValidateEvent (targetControl.UniqueID, eventArgument);
  1318. #endif
  1319. sourceControl.RaisePostBackEvent (eventArgument);
  1320. }
  1321. #if NET_2_0
  1322. [Obsolete]
  1323. #endif
  1324. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1325. public void RegisterArrayDeclaration (string arrayName, string arrayValue)
  1326. {
  1327. scriptManager.RegisterArrayDeclaration (arrayName, arrayValue);
  1328. }
  1329. #if NET_2_0
  1330. [Obsolete]
  1331. #endif
  1332. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1333. public virtual void RegisterClientScriptBlock (string key, string script)
  1334. {
  1335. scriptManager.RegisterClientScriptBlock (key, script);
  1336. }
  1337. #if NET_2_0
  1338. [Obsolete]
  1339. #endif
  1340. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1341. public virtual void RegisterHiddenField (string hiddenFieldName, string hiddenFieldInitialValue)
  1342. {
  1343. scriptManager.RegisterHiddenField (hiddenFieldName, hiddenFieldInitialValue);
  1344. }
  1345. [MonoTODO("Not implemented, Used in HtmlForm")]
  1346. internal void RegisterClientScriptFile (string a, string b, string c)
  1347. {
  1348. throw new NotImplementedException ();
  1349. }
  1350. #if NET_2_0
  1351. [Obsolete]
  1352. #endif
  1353. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1354. public void RegisterOnSubmitStatement (string key, string script)
  1355. {
  1356. scriptManager.RegisterOnSubmitStatement (key, script);
  1357. }
  1358. internal string GetSubmitStatements ()
  1359. {
  1360. return scriptManager.WriteSubmitStatements ();
  1361. }
  1362. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1363. public void RegisterRequiresPostBack (Control control)
  1364. {
  1365. #if NET_2_0
  1366. if (!(control is IPostBackDataHandler))
  1367. throw new HttpException ("The control to register does not implement the IPostBackDataHandler interface.");
  1368. #endif
  1369. if (_requiresPostBack == null)
  1370. _requiresPostBack = new ArrayList ();
  1371. if (_requiresPostBack.Contains (control.UniqueID))
  1372. return;
  1373. _requiresPostBack.Add (control.UniqueID);
  1374. }
  1375. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1376. public virtual void RegisterRequiresRaiseEvent (IPostBackEventHandler control)
  1377. {
  1378. requiresRaiseEvent = control;
  1379. }
  1380. #if NET_2_0
  1381. [Obsolete]
  1382. #endif
  1383. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1384. public virtual void RegisterStartupScript (string key, string script)
  1385. {
  1386. scriptManager.RegisterStartupScript (key, script);
  1387. }
  1388. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1389. public void RegisterViewStateHandler ()
  1390. {
  1391. handleViewState = true;
  1392. }
  1393. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1394. protected virtual void SavePageStateToPersistenceMedium (object viewState)
  1395. {
  1396. PageStatePersister persister = this.PageStatePersister;
  1397. if (persister == null)
  1398. return;
  1399. Pair pair = viewState as Pair;
  1400. if (pair != null) {
  1401. persister.ViewState = pair.First;
  1402. persister.ControlState = pair.Second;
  1403. } else
  1404. persister.ViewState = viewState;
  1405. persister.Save ();
  1406. }
  1407. internal string RawViewState {
  1408. get {
  1409. NameValueCollection postdata = _requestValueCollection;
  1410. string view_state;
  1411. if (postdata == null || (view_state = postdata ["__VIEWSTATE"]) == null)
  1412. return null;
  1413. if (view_state == "")
  1414. return null;
  1415. return view_state;
  1416. }
  1417. set { _savedViewState = value; }
  1418. }
  1419. #if NET_2_0
  1420. protected virtual
  1421. #else
  1422. internal
  1423. #endif
  1424. PageStatePersister PageStatePersister {
  1425. get {
  1426. if (page_state_persister == null)
  1427. page_state_persister = new HiddenFieldPageStatePersister (this);
  1428. return page_state_persister;
  1429. }
  1430. }
  1431. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1432. protected virtual object LoadPageStateFromPersistenceMedium ()
  1433. {
  1434. PageStatePersister persister = this.PageStatePersister;
  1435. if (persister == null)
  1436. return null;
  1437. persister.Load ();
  1438. return new Pair (persister.ViewState, persister.ControlState);
  1439. }
  1440. internal void LoadPageViewState()
  1441. {
  1442. Pair sState = LoadPageStateFromPersistenceMedium () as Pair;
  1443. if (sState != null) {
  1444. if (allow_load) {
  1445. #if NET_2_0
  1446. LoadPageControlState (sState.Second);
  1447. #endif
  1448. Pair vsr = sState.First as Pair;
  1449. if (vsr != null) {
  1450. LoadViewStateRecursive (vsr.First);
  1451. _requiresPostBackCopy = vsr.Second as ArrayList;
  1452. }
  1453. }
  1454. }
  1455. }
  1456. internal void SavePageViewState ()
  1457. {
  1458. if (!handleViewState)
  1459. return;
  1460. #if NET_2_0
  1461. object controlState = SavePageControlState ();
  1462. #endif
  1463. object viewState = SaveViewStateRecursive ();
  1464. object reqPostback = (_requiresPostBack != null && _requiresPostBack.Count > 0) ? _requiresPostBack : null;
  1465. Pair vsr = null;
  1466. if (viewState != null || reqPostback != null)
  1467. vsr = new Pair (viewState, reqPostback);
  1468. Pair pair = new Pair ();
  1469. pair.First = vsr;
  1470. #if NET_2_0
  1471. pair.Second = controlState;
  1472. #else
  1473. pair.Second = null;
  1474. #endif
  1475. if (pair.First == null && pair.Second == null)
  1476. SavePageStateToPersistenceMedium (null);
  1477. else
  1478. SavePageStateToPersistenceMedium (pair);
  1479. }
  1480. public virtual void Validate ()
  1481. {
  1482. is_validated = true;
  1483. ValidateCollection (_validators);
  1484. }
  1485. #if NET_2_0
  1486. internal bool AreValidatorsUplevel () {
  1487. return AreValidatorsUplevel (String.Empty);
  1488. }
  1489. internal bool AreValidatorsUplevel (string valGroup)
  1490. #else
  1491. internal virtual bool AreValidatorsUplevel ()
  1492. #endif
  1493. {
  1494. bool uplevel = false;
  1495. foreach (IValidator v in Validators) {
  1496. BaseValidator bv = v as BaseValidator;
  1497. if (bv == null) continue;
  1498. #if NET_2_0
  1499. if (valGroup != bv.ValidationGroup)
  1500. continue;
  1501. #endif
  1502. if (bv.GetRenderUplevel()) {
  1503. uplevel = true;
  1504. break;
  1505. }
  1506. }
  1507. return uplevel;
  1508. }
  1509. bool ValidateCollection (ValidatorCollection validators)
  1510. {
  1511. #if NET_2_0
  1512. if (!_eventValidation)
  1513. return true;
  1514. #endif
  1515. if (validators == null || validators.Count == 0)
  1516. return true;
  1517. bool all_valid = true;
  1518. foreach (IValidator v in validators){
  1519. v.Validate ();
  1520. if (v.IsValid == false)
  1521. all_valid = false;
  1522. }
  1523. return all_valid;
  1524. }
  1525. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1526. public virtual void VerifyRenderingInServerForm (Control control)
  1527. {
  1528. if (Context == null)
  1529. return;
  1530. #if NET_2_0
  1531. if (IsCallback)
  1532. return;
  1533. #endif
  1534. if (!renderingForm)
  1535. throw new HttpException ("Control '" +
  1536. control.ClientID +
  1537. "' of type '" +
  1538. control.GetType ().Name +
  1539. "' must be placed inside a form tag with runat=server.");
  1540. }
  1541. protected override void FrameworkInitialize ()
  1542. {
  1543. base.FrameworkInitialize ();
  1544. #if NET_2_0
  1545. InitializeStyleSheet ();
  1546. #endif
  1547. }
  1548. #endregion
  1549. #if NET_2_0
  1550. public
  1551. #else
  1552. internal
  1553. #endif
  1554. ClientScriptManager ClientScript {
  1555. get { return scriptManager; }
  1556. }
  1557. #if NET_2_0
  1558. static readonly object InitCompleteEvent = new object ();
  1559. static readonly object LoadCompleteEvent = new object ();
  1560. static readonly object PreInitEvent = new object ();
  1561. static readonly object PreLoadEvent = new object ();
  1562. static readonly object PreRenderCompleteEvent = new object ();
  1563. static readonly object SaveStateCompleteEvent = new object ();
  1564. int event_mask;
  1565. const int initcomplete_mask = 1;
  1566. const int loadcomplete_mask = 1 << 1;
  1567. const int preinit_mask = 1 << 2;
  1568. const int preload_mask = 1 << 3;
  1569. const int prerendercomplete_mask = 1 << 4;
  1570. const int savestatecomplete_mask = 1 << 5;
  1571. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1572. public event EventHandler InitComplete {
  1573. add {
  1574. event_mask |= initcomplete_mask;
  1575. Events.AddHandler (InitCompleteEvent, value);
  1576. }
  1577. remove { Events.RemoveHandler (InitCompleteEvent, value); }
  1578. }
  1579. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1580. public event EventHandler LoadComplete {
  1581. add {
  1582. event_mask |= loadcomplete_mask;
  1583. Events.AddHandler (LoadCompleteEvent, value);
  1584. }
  1585. remove { Events.RemoveHandler (LoadCompleteEvent, value); }
  1586. }
  1587. public event EventHandler PreInit {
  1588. add {
  1589. event_mask |= preinit_mask;
  1590. Events.AddHandler (PreInitEvent, value);
  1591. }
  1592. remove { Events.RemoveHandler (PreInitEvent, value); }
  1593. }
  1594. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1595. public event EventHandler PreLoad {
  1596. add {
  1597. event_mask |= preload_mask;
  1598. Events.AddHandler (PreLoadEvent, value);
  1599. }
  1600. remove { Events.RemoveHandler (PreLoadEvent, value); }
  1601. }
  1602. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1603. public event EventHandler PreRenderComplete {
  1604. add {
  1605. event_mask |= prerendercomplete_mask;
  1606. Events.AddHandler (PreRenderCompleteEvent, value);
  1607. }
  1608. remove { Events.RemoveHandler (PreRenderCompleteEvent, value); }
  1609. }
  1610. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1611. public event EventHandler SaveStateComplete {
  1612. add {
  1613. event_mask |= savestatecomplete_mask;
  1614. Events.AddHandler (SaveStateCompleteEvent, value);
  1615. }
  1616. remove { Events.RemoveHandler (SaveStateCompleteEvent, value); }
  1617. }
  1618. protected virtual void OnInitComplete (EventArgs e)
  1619. {
  1620. if ((event_mask & initcomplete_mask) != 0) {
  1621. EventHandler eh = (EventHandler) (Events [InitCompleteEvent]);
  1622. if (eh != null) eh (this, e);
  1623. }
  1624. }
  1625. protected virtual void OnLoadComplete (EventArgs e)
  1626. {
  1627. if ((event_mask & loadcomplete_mask) != 0) {
  1628. EventHandler eh = (EventHandler) (Events [LoadCompleteEvent]);
  1629. if (eh != null) eh (this, e);
  1630. }
  1631. }
  1632. protected virtual void OnPreInit (EventArgs e)
  1633. {
  1634. if ((event_mask & preinit_mask) != 0) {
  1635. EventHandler eh = (EventHandler) (Events [PreInitEvent]);
  1636. if (eh != null) eh (this, e);
  1637. }
  1638. }
  1639. protected virtual void OnPreLoad (EventArgs e)
  1640. {
  1641. if ((event_mask & preload_mask) != 0) {
  1642. EventHandler eh = (EventHandler) (Events [PreLoadEvent]);
  1643. if (eh != null) eh (this, e);
  1644. }
  1645. }
  1646. protected virtual void OnPreRenderComplete (EventArgs e)
  1647. {
  1648. if ((event_mask & prerendercomplete_mask) != 0) {
  1649. EventHandler eh = (EventHandler) (Events [PreRenderCompleteEvent]);
  1650. if (eh != null) eh (this, e);
  1651. }
  1652. if (Form == null)
  1653. return;
  1654. if (!Form.DetermineRenderUplevel ())
  1655. return;
  1656. /* figure out if we have some control we're going to focus */
  1657. if (String.IsNullOrEmpty (_focusedControlID)) {
  1658. _focusedControlID = Form.DefaultFocus;
  1659. if (String.IsNullOrEmpty (_focusedControlID))
  1660. _focusedControlID = Form.DefaultButton;
  1661. }
  1662. if (!String.IsNullOrEmpty (_focusedControlID)) {
  1663. ClientScript.RegisterWebFormClientScript ();
  1664. ClientScript.RegisterStartupScript (
  1665. "HtmlForm-DefaultButton-StartupScript",
  1666. String.Format (
  1667. "<script type=\"text/javascript\">\n{0}WebForm_AutoFocus('{1}');{2}\n</script>\n",
  1668. ClientScriptManager.SCRIPT_BLOCK_START,
  1669. _focusedControlID,
  1670. ClientScriptManager.SCRIPT_BLOCK_END)
  1671. );
  1672. }
  1673. if (Form.SubmitDisabledControls && _hasEnabledControlArray) {
  1674. ClientScript.RegisterWebFormClientScript ();
  1675. ClientScript.RegisterOnSubmitStatement ("HtmlForm-SubmitDisabledControls-SubmitStatement",
  1676. "WebForm_ReEnableControls(this);");
  1677. }
  1678. }
  1679. internal void RegisterEnabledControl (Control control)
  1680. {
  1681. if (Form == null || !Page.Form.SubmitDisabledControls || !Page.Form.DetermineRenderUplevel ())
  1682. return;
  1683. _hasEnabledControlArray = true;
  1684. Page.ClientScript.RegisterArrayDeclaration (EnabledControlArrayID, String.Format ("'{0}'", control.ClientID));
  1685. }
  1686. protected virtual void OnSaveStateComplete (EventArgs e)
  1687. {
  1688. if ((event_mask & savestatecomplete_mask) != 0) {
  1689. EventHandler eh = (EventHandler) (Events [SaveStateCompleteEvent]);
  1690. if (eh != null) eh (this, e);
  1691. }
  1692. }
  1693. public HtmlForm Form {
  1694. get { return _form; }
  1695. }
  1696. internal void RegisterForm (HtmlForm form)
  1697. {
  1698. _form = form;
  1699. }
  1700. [BrowsableAttribute (false)]
  1701. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  1702. public Page PreviousPage {
  1703. get {
  1704. if (_doLoadPreviousPage) {
  1705. _doLoadPreviousPage = false;
  1706. LoadPreviousPageReference ();
  1707. }
  1708. return previousPage;
  1709. }
  1710. }
  1711. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  1712. [BrowsableAttribute (false)]
  1713. public bool IsCallback {
  1714. get { return isCallback; }
  1715. }
  1716. [BrowsableAttribute (false)]
  1717. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  1718. public bool IsCrossPagePostBack {
  1719. get { return isCrossPagePostBack; }
  1720. }
  1721. public new virtual char IdSeparator {
  1722. get {
  1723. //TODO: why override?
  1724. return base.IdSeparator;
  1725. }
  1726. }
  1727. string ProcessCallbackData ()
  1728. {
  1729. string callbackTarget = _requestValueCollection [CallbackSourceID];
  1730. if (callbackTarget == null || callbackTarget.Length == 0)
  1731. throw new HttpException ("Callback target not provided.");
  1732. Control targetControl = FindControl (callbackTarget);
  1733. ICallbackEventHandler target = targetControl as ICallbackEventHandler;
  1734. if (target == null)
  1735. throw new HttpException (string.Format ("Invalid callback target '{0}'.", callbackTarget));
  1736. string callbackEventError = String.Empty;
  1737. string callBackResult;
  1738. string callbackArgument = _requestValueCollection [CallbackArgumentID];
  1739. try {
  1740. target.RaiseCallbackEvent (callbackArgument);
  1741. }
  1742. catch (Exception ex) {
  1743. callbackEventError = String.Format ("e{0}", ex.Message);
  1744. }
  1745. try {
  1746. callBackResult = target.GetCallbackResult ();
  1747. }
  1748. catch (Exception ex) {
  1749. return String.Format ("e{0}", ex.Message);
  1750. }
  1751. string eventValidation = ClientScript.GetEventValidationStateFormatted ();
  1752. return String.Format ("{0}{1}|{2}{3}", callbackEventError, eventValidation == null ? 0 : eventValidation.Length, eventValidation, callBackResult);
  1753. }
  1754. [BrowsableAttribute (false)]
  1755. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  1756. public HtmlHead Header {
  1757. get { return htmlHeader; }
  1758. }
  1759. internal void SetHeader (HtmlHead header)
  1760. {
  1761. htmlHeader = header;
  1762. if (_title != null) {
  1763. htmlHeader.Title = _title;
  1764. _title = null;
  1765. }
  1766. }
  1767. protected bool AsyncMode {
  1768. get { return asyncMode; }
  1769. set { asyncMode = value; }
  1770. }
  1771. public TimeSpan AsyncTimeout {
  1772. get { return asyncTimeout; }
  1773. set { asyncTimeout = value; }
  1774. }
  1775. public bool IsAsync {
  1776. get { return AsyncMode; }
  1777. }
  1778. [MonoTODO ("Not Implemented")]
  1779. protected internal virtual string UniqueFilePathSuffix {
  1780. get {
  1781. throw new NotImplementedException ();
  1782. }
  1783. }
  1784. [MonoTODO ("Not Implemented")]
  1785. public int MaxPageStateFieldLength {
  1786. get {
  1787. throw new NotImplementedException ();
  1788. }
  1789. set {
  1790. throw new NotImplementedException ();
  1791. }
  1792. }
  1793. public void AddOnPreRenderCompleteAsync (BeginEventHandler beginHandler, EndEventHandler endHandler)
  1794. {
  1795. AddOnPreRenderCompleteAsync (beginHandler, endHandler, null);
  1796. }
  1797. public void AddOnPreRenderCompleteAsync (BeginEventHandler beginHandler, EndEventHandler endHandler, Object state)
  1798. {
  1799. if (!IsAsync) {
  1800. throw new InvalidOperationException ("AddOnPreRenderCompleteAsync called and Page.IsAsync == false");
  1801. }
  1802. if (_lifeCycle >= PageLifeCycle.PreRender) {
  1803. throw new InvalidOperationException ("AddOnPreRenderCompleteAsync can only be called before PreRender.");
  1804. }
  1805. if (beginHandler == null) {
  1806. throw new ArgumentNullException ("beginHandler");
  1807. }
  1808. if (endHandler == null) {
  1809. throw new ArgumentNullException ("endHandler");
  1810. }
  1811. RegisterAsyncTask (new PageAsyncTask (beginHandler, endHandler, null, state, false));
  1812. }
  1813. private List<PageAsyncTask> ParallelTasks {
  1814. get {
  1815. if (parallelTasks == null) {
  1816. parallelTasks = new List<PageAsyncTask>();
  1817. }
  1818. return parallelTasks;
  1819. }
  1820. }
  1821. private List<PageAsyncTask> SerialTasks {
  1822. get {
  1823. if (serialTasks == null) {
  1824. serialTasks = new List<PageAsyncTask> ();
  1825. }
  1826. return serialTasks;
  1827. }
  1828. }
  1829. public void RegisterAsyncTask (PageAsyncTask task)
  1830. {
  1831. if (task == null) {
  1832. throw new ArgumentNullException ("task");
  1833. }
  1834. if (task.ExecuteInParallel) {
  1835. ParallelTasks.Add (task);
  1836. }
  1837. else {
  1838. SerialTasks.Add (task);
  1839. }
  1840. }
  1841. public void ExecuteRegisteredAsyncTasks ()
  1842. {
  1843. if ((parallelTasks == null || parallelTasks.Count == 0) &&
  1844. (serialTasks == null || serialTasks.Count == 0)){
  1845. return;
  1846. }
  1847. if (parallelTasks != null) {
  1848. DateTime startExecution = DateTime.Now;
  1849. List<PageAsyncTask> localParallelTasks = parallelTasks;
  1850. parallelTasks = null; // Shouldn't execute tasks twice
  1851. List<IAsyncResult> asyncResults = new List<IAsyncResult>();
  1852. foreach (PageAsyncTask parallelTask in localParallelTasks) {
  1853. IAsyncResult result = parallelTask.BeginHandler (this, EventArgs.Empty, new AsyncCallback (EndAsyncTaskCallback), parallelTask.State);
  1854. if (result.CompletedSynchronously) {
  1855. parallelTask.EndHandler (result);
  1856. }
  1857. else {
  1858. asyncResults.Add (result);
  1859. }
  1860. }
  1861. if (asyncResults.Count > 0) {
  1862. #if TARGET_JVM
  1863. TimeSpan timeout = AsyncTimeout;
  1864. long t1 = DateTime.Now.Ticks;
  1865. bool signalled = true;
  1866. for (int i = 0; i < asyncResults.Count; i++) {
  1867. if (asyncResults [i].IsCompleted)
  1868. continue;
  1869. if (signalled)
  1870. signalled = asyncResults [i].AsyncWaitHandle.WaitOne (timeout, false);
  1871. if (signalled) {
  1872. long t2 = DateTime.Now.Ticks;
  1873. timeout = AsyncTimeout - TimeSpan.FromTicks (t2 - t1);
  1874. if (timeout.Ticks <= 0)
  1875. signalled = false;
  1876. }
  1877. else {
  1878. localParallelTasks [i].TimeoutHandler (asyncResults [i]);
  1879. }
  1880. }
  1881. #else
  1882. WaitHandle [] waitArray = new WaitHandle [asyncResults.Count];
  1883. int i = 0;
  1884. for (i = 0; i < asyncResults.Count; i++) {
  1885. waitArray [i] = asyncResults [i].AsyncWaitHandle;
  1886. }
  1887. bool allSignalled = WaitHandle.WaitAll (waitArray, AsyncTimeout, false);
  1888. if (!allSignalled) {
  1889. for (i = 0; i < asyncResults.Count; i++) {
  1890. if (!asyncResults [i].IsCompleted) {
  1891. localParallelTasks [i].TimeoutHandler (asyncResults [i]);
  1892. }
  1893. }
  1894. }
  1895. #endif
  1896. }
  1897. DateTime endWait = DateTime.Now;
  1898. TimeSpan elapsed = endWait - startExecution;
  1899. if (elapsed <= AsyncTimeout) {
  1900. AsyncTimeout -= elapsed;
  1901. }
  1902. else {
  1903. AsyncTimeout = TimeSpan.FromTicks(0);
  1904. }
  1905. }
  1906. if (serialTasks != null) {
  1907. List<PageAsyncTask> localSerialTasks = serialTasks;
  1908. serialTasks = null; // Shouldn't execute tasks twice
  1909. foreach (PageAsyncTask serialTask in localSerialTasks) {
  1910. DateTime startExecution = DateTime.Now;
  1911. IAsyncResult result = serialTask.BeginHandler (this, EventArgs.Empty, new AsyncCallback (EndAsyncTaskCallback), serialTask);
  1912. if (result.CompletedSynchronously) {
  1913. serialTask.EndHandler (result);
  1914. }
  1915. else {
  1916. bool done = result.AsyncWaitHandle.WaitOne (AsyncTimeout, false);
  1917. if (!done && !result.IsCompleted) {
  1918. serialTask.TimeoutHandler (result);
  1919. }
  1920. }
  1921. DateTime endWait = DateTime.Now;
  1922. TimeSpan elapsed = endWait - startExecution;
  1923. if (elapsed <= AsyncTimeout) {
  1924. AsyncTimeout -= elapsed;
  1925. }
  1926. else {
  1927. AsyncTimeout = TimeSpan.FromTicks (0);
  1928. }
  1929. }
  1930. }
  1931. AsyncTimeout = TimeSpan.FromSeconds (DefaultAsyncTimeout);
  1932. }
  1933. void EndAsyncTaskCallback (IAsyncResult result)
  1934. {
  1935. PageAsyncTask task = (PageAsyncTask)result.AsyncState;
  1936. task.EndHandler (result);
  1937. }
  1938. public static HtmlTextWriter CreateHtmlTextWriterFromType (TextWriter tw, Type writerType)
  1939. {
  1940. Type htmlTextWriterType = typeof (HtmlTextWriter);
  1941. if (!htmlTextWriterType.IsAssignableFrom (writerType)) {
  1942. throw new HttpException (String.Format ("Type '{0}' cannot be assigned to HtmlTextWriter", writerType.FullName));
  1943. }
  1944. ConstructorInfo constructor = writerType.GetConstructor (new Type [] { typeof (TextWriter) });
  1945. if (constructor == null) {
  1946. throw new HttpException (String.Format ("Type '{0}' does not have a consturctor that takes a TextWriter as parameter", writerType.FullName));
  1947. }
  1948. return (HtmlTextWriter) Activator.CreateInstance(writerType, tw);
  1949. }
  1950. public ViewStateEncryptionMode ViewStateEncryptionMode {
  1951. get { return viewStateEncryptionMode; }
  1952. set { viewStateEncryptionMode = value; }
  1953. }
  1954. public void RegisterRequiresViewStateEncryption ()
  1955. {
  1956. controlRegisteredForViewStateEncryption = true;
  1957. }
  1958. private static byte [] AES_IV = null;
  1959. private static byte [] TripleDES_IV = null;
  1960. private static object locker = new object ();
  1961. private static bool isEncryptionInitialized = false;
  1962. private static void InitializeEncryption ()
  1963. {
  1964. if (isEncryptionInitialized) {
  1965. return;
  1966. }
  1967. lock (locker) {
  1968. if (isEncryptionInitialized) {
  1969. return;
  1970. }
  1971. string iv_string = "0BA48A9E-736D-40f8-954B-B2F62241F282";
  1972. AES_IV = new byte [16];
  1973. TripleDES_IV = new byte [8];
  1974. int i;
  1975. for (i = 0; i < AES_IV.Length; i++) {
  1976. AES_IV [i] = (byte) iv_string [i];
  1977. }
  1978. for (i = 0; i < TripleDES_IV.Length; i++) {
  1979. TripleDES_IV [i] = (byte) iv_string [i];
  1980. }
  1981. isEncryptionInitialized = true;
  1982. }
  1983. }
  1984. internal ICryptoTransform GetCryptoTransform (CryptoStreamMode cryptoStreamMode)
  1985. {
  1986. ICryptoTransform transform = null;
  1987. MachineKeySection config = (MachineKeySection) WebConfigurationManager.GetSection (machineKeyConfigPath);
  1988. byte [] vk = MachineKeySectionUtils.ValidationKeyBytes (config);
  1989. switch (config.Validation) {
  1990. case MachineKeyValidation.SHA1:
  1991. transform = SHA1.Create ();
  1992. break;
  1993. case MachineKeyValidation.MD5:
  1994. transform = MD5.Create ();
  1995. break;
  1996. case MachineKeyValidation.AES:
  1997. if (cryptoStreamMode == CryptoStreamMode.Read){
  1998. transform = Rijndael.Create().CreateDecryptor(vk, AES_IV);
  1999. } else {
  2000. transform = Rijndael.Create().CreateEncryptor(vk, AES_IV);
  2001. }
  2002. break;
  2003. case MachineKeyValidation.TripleDES:
  2004. if (cryptoStreamMode == CryptoStreamMode.Read){
  2005. transform = TripleDES.Create().CreateDecryptor(vk, TripleDES_IV);
  2006. } else {
  2007. transform = TripleDES.Create().CreateEncryptor(vk, TripleDES_IV);
  2008. }
  2009. break;
  2010. }
  2011. return transform;
  2012. }
  2013. internal bool NeedViewStateEncryption {
  2014. get {
  2015. return (ViewStateEncryptionMode == ViewStateEncryptionMode.Always ||
  2016. (ViewStateEncryptionMode == ViewStateEncryptionMode.Auto &&
  2017. controlRegisteredForViewStateEncryption));
  2018. }
  2019. }
  2020. void ApplyMasterPage ()
  2021. {
  2022. if (masterPageFile != null && masterPageFile.Length > 0) {
  2023. ArrayList appliedMasterPageFiles = new ArrayList ();
  2024. if (Master != null) {
  2025. MasterPage.ApplyMasterPageRecursive (Master, appliedMasterPageFiles);
  2026. Master.Page = this;
  2027. Controls.Clear ();
  2028. Controls.Add (Master);
  2029. }
  2030. }
  2031. }
  2032. [DefaultValueAttribute ("")]
  2033. public virtual string MasterPageFile {
  2034. get { return masterPageFile; }
  2035. set {
  2036. masterPageFile = value;
  2037. masterPage = null;
  2038. }
  2039. }
  2040. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  2041. [BrowsableAttribute (false)]
  2042. public MasterPage Master {
  2043. get {
  2044. if (Context == null || String.IsNullOrEmpty (masterPageFile))
  2045. return null;
  2046. if (masterPage == null)
  2047. masterPage = MasterPage.CreateMasterPage (this, Context, masterPageFile, contentTemplates);
  2048. return masterPage;
  2049. }
  2050. }
  2051. public void SetFocus (string clientID)
  2052. {
  2053. if (String.IsNullOrEmpty (clientID))
  2054. throw new ArgumentNullException ("control");
  2055. if (_lifeCycle > PageLifeCycle.PreRender)
  2056. throw new InvalidOperationException ("SetFocus can only be called before and during PreRender.");
  2057. if(Form==null)
  2058. throw new InvalidOperationException ("A form tag with runat=server must exist on the Page to use SetFocus() or the Focus property.");
  2059. _focusedControlID = clientID;
  2060. }
  2061. public void SetFocus (Control control)
  2062. {
  2063. if (control == null)
  2064. throw new ArgumentNullException ("control");
  2065. SetFocus (control.ClientID);
  2066. }
  2067. [EditorBrowsable (EditorBrowsableState.Advanced)]
  2068. public void RegisterRequiresControlState (Control control)
  2069. {
  2070. if (control == null)
  2071. throw new ArgumentNullException ("control");
  2072. if (RequiresControlState (control))
  2073. return;
  2074. if (requireStateControls == null)
  2075. requireStateControls = new ArrayList ();
  2076. int n = requireStateControls.Add (control);
  2077. if (_savedControlState == null || n >= _savedControlState.Length)
  2078. return;
  2079. for (Control parent = control.Parent; parent != null; parent = parent.Parent)
  2080. if (parent.IsChildControlStateCleared)
  2081. return;
  2082. object state = _savedControlState [n];
  2083. if (state != null)
  2084. control.LoadControlState (state);
  2085. }
  2086. public bool RequiresControlState (Control control)
  2087. {
  2088. if (requireStateControls == null) return false;
  2089. return requireStateControls.Contains (control);
  2090. }
  2091. [EditorBrowsable (EditorBrowsableState.Advanced)]
  2092. public void UnregisterRequiresControlState (Control control)
  2093. {
  2094. if (requireStateControls != null)
  2095. requireStateControls.Remove (control);
  2096. }
  2097. public ValidatorCollection GetValidators (string validationGroup)
  2098. {
  2099. if (validationGroup == String.Empty)
  2100. validationGroup = null;
  2101. ValidatorCollection col = new ValidatorCollection ();
  2102. if (_validators == null)
  2103. return col;
  2104. foreach (IValidator v in _validators)
  2105. if (BelongsToGroup(v, validationGroup))
  2106. col.Add(v);
  2107. return col;
  2108. }
  2109. bool BelongsToGroup(IValidator v, string validationGroup) {
  2110. BaseValidator validator = v as BaseValidator;
  2111. if (validationGroup == null)
  2112. return validator == null || String.IsNullOrEmpty (validator.ValidationGroup);
  2113. else
  2114. return validator != null && validator.ValidationGroup == validationGroup;
  2115. }
  2116. public virtual void Validate (string validationGroup)
  2117. {
  2118. is_validated = true;
  2119. ValidateCollection (GetValidators (validationGroup));
  2120. }
  2121. object SavePageControlState ()
  2122. {
  2123. if (requireStateControls == null) return null;
  2124. object[] state = new object [requireStateControls.Count];
  2125. bool allNull = true;
  2126. for (int n=0; n<state.Length; n++) {
  2127. state [n] = ((Control) requireStateControls [n]).SaveControlState ();
  2128. if (state [n] != null) allNull = false;
  2129. }
  2130. if (allNull) return null;
  2131. else return state;
  2132. }
  2133. void LoadPageControlState (object data)
  2134. {
  2135. _savedControlState = (object []) data;
  2136. if (requireStateControls == null) return;
  2137. int max = Math.Min (requireStateControls.Count, _savedControlState != null ? _savedControlState.Length : requireStateControls.Count);
  2138. for (int n=0; n < max; n++) {
  2139. Control ctl = (Control) requireStateControls [n];
  2140. ctl.LoadControlState (_savedControlState != null ? _savedControlState [n] : null);
  2141. }
  2142. }
  2143. void LoadPreviousPageReference ()
  2144. {
  2145. if (_requestValueCollection != null) {
  2146. string prevPage = _requestValueCollection [PreviousPageID];
  2147. if (prevPage != null) {
  2148. previousPage = (Page) PageParser.GetCompiledPageInstance (prevPage, Server.MapPath (prevPage), Context);
  2149. previousPage.ProcessCrossPagePostBack (Context);
  2150. }
  2151. }
  2152. }
  2153. Hashtable contentTemplates;
  2154. [EditorBrowsable (EditorBrowsableState.Never)]
  2155. protected internal void AddContentTemplate (string templateName, ITemplate template)
  2156. {
  2157. if (contentTemplates == null)
  2158. contentTemplates = new Hashtable ();
  2159. contentTemplates [templateName] = template;
  2160. }
  2161. PageTheme _pageTheme;
  2162. internal PageTheme PageTheme {
  2163. get { return _pageTheme; }
  2164. }
  2165. PageTheme _styleSheetPageTheme;
  2166. internal PageTheme StyleSheetPageTheme {
  2167. get { return _styleSheetPageTheme; }
  2168. }
  2169. Stack dataItemCtx;
  2170. internal void PushDataItemContext (object o) {
  2171. if (dataItemCtx == null)
  2172. dataItemCtx = new Stack ();
  2173. dataItemCtx.Push (o);
  2174. }
  2175. internal void PopDataItemContext () {
  2176. if (dataItemCtx == null)
  2177. throw new InvalidOperationException ();
  2178. dataItemCtx.Pop ();
  2179. }
  2180. public object GetDataItem() {
  2181. if (dataItemCtx == null || dataItemCtx.Count == 0)
  2182. throw new InvalidOperationException ("No data item");
  2183. return dataItemCtx.Peek ();
  2184. }
  2185. protected internal override void OnInit (EventArgs e)
  2186. {
  2187. base.OnInit (e);
  2188. ArrayList themes = new ArrayList();
  2189. if (StyleSheetPageTheme != null && StyleSheetPageTheme.GetStyleSheets () != null)
  2190. themes.AddRange (StyleSheetPageTheme.GetStyleSheets ());
  2191. if (PageTheme != null && PageTheme.GetStyleSheets () != null)
  2192. themes.AddRange (PageTheme.GetStyleSheets ());
  2193. if (themes.Count > 0 && Header == null)
  2194. throw new InvalidOperationException ("Using themed css files requires a header control on the page.");
  2195. foreach (string lss in themes) {
  2196. HtmlLink hl = new HtmlLink ();
  2197. hl.Href = ResolveUrl (lss);
  2198. hl.Attributes["type"] = "text/css";
  2199. hl.Attributes["rel"] = "stylesheet";
  2200. Header.Controls.Add (hl);
  2201. }
  2202. }
  2203. #endif
  2204. #if NET_2_0
  2205. [MonoTODO ("Not implemented. Only used by .net aspx parser")]
  2206. protected object GetWrappedFileDependencies (string [] list)
  2207. {
  2208. return list;
  2209. }
  2210. [MonoTODO ("Does nothing. Used by .net aspx parser")]
  2211. protected virtual void InitializeCulture ()
  2212. {
  2213. }
  2214. [MonoTODO ("Does nothing. Used by .net aspx parser")]
  2215. protected internal void AddWrappedFileDependencies (object virtualFileDependencies)
  2216. {
  2217. }
  2218. #endif
  2219. }
  2220. }