Fix bugs in sizing TableLayoutPanel (Xamarin bug 18638)
[mono.git] / mcs / class / System.Web.Mvc / System.Web.Mvc / ViewPage`1.cs
1 /* ****************************************************************************\r
2  *\r
3  * Copyright (c) Microsoft Corporation. All rights reserved.\r
4  *\r
5  * This software is subject to the Microsoft Public License (Ms-PL). \r
6  * A copy of the license can be found in the license.htm file included \r
7  * in this distribution.\r
8  *\r
9  * You must not remove this notice, or any other, from this software.\r
10  *\r
11  * ***************************************************************************/\r
12 \r
13 namespace System.Web.Mvc {\r
14     using System.Diagnostics.CodeAnalysis;\r
15 \r
16     public class ViewPage<TModel> : ViewPage where TModel : class {\r
17 \r
18         private ViewDataDictionary<TModel> _viewData;\r
19 \r
20         public new AjaxHelper<TModel> Ajax {\r
21             get;\r
22             set;\r
23         }\r
24 \r
25         public new HtmlHelper<TModel> Html {\r
26             get;\r
27             set;\r
28         }\r
29 \r
30         public new TModel Model {\r
31             get {\r
32                 return ViewData.Model;\r
33             }\r
34         }\r
35 \r
36         [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]\r
37         public new ViewDataDictionary<TModel> ViewData {\r
38             get {\r
39                 if (_viewData == null) {\r
40                     SetViewData(new ViewDataDictionary<TModel>());\r
41                 }\r
42                 return _viewData;\r
43             }\r
44             set {\r
45                 SetViewData(value);\r
46             }\r
47         }\r
48 \r
49         public override void InitHelpers() {\r
50             base.InitHelpers();\r
51 \r
52             Ajax = new AjaxHelper<TModel>(ViewContext, this);\r
53             Html = new HtmlHelper<TModel>(ViewContext, this);\r
54         }\r
55 \r
56         protected override void SetViewData(ViewDataDictionary viewData) {\r
57             _viewData = new ViewDataDictionary<TModel>(viewData);\r
58 \r
59             base.SetViewData(_viewData);\r
60         }\r
61     }\r
62 }\r