2010-06-21 Marek Habersack <mhabersack@novell.com>
[mcs.git] / class / System.Web.Mvc / System.Web.Mvc / ViewUserControl`1.cs
blob41e19498acded04738305214ced575d6669cffdd
1 /* ****************************************************************************
3 * Copyright (c) Microsoft Corporation. All rights reserved.
5 * This software is subject to the Microsoft Public License (Ms-PL).
6 * A copy of the license can be found in the license.htm file included
7 * in this distribution.
9 * You must not remove this notice, or any other, from this software.
11 * ***************************************************************************/
13 namespace System.Web.Mvc {
14 using System.Diagnostics.CodeAnalysis;
16 public class ViewUserControl<TModel> : ViewUserControl where TModel : class {
17 private AjaxHelper<TModel> _ajaxHelper;
18 private HtmlHelper<TModel> _htmlHelper;
19 private ViewDataDictionary<TModel> _viewData;
21 public new AjaxHelper<TModel> Ajax {
22 get {
23 if (_ajaxHelper == null) {
24 _ajaxHelper = new AjaxHelper<TModel>(ViewContext, this);
26 return _ajaxHelper;
30 public new HtmlHelper<TModel> Html {
31 get {
32 if (_htmlHelper == null) {
33 _htmlHelper = new HtmlHelper<TModel>(ViewContext, this);
35 return _htmlHelper;
39 public new TModel Model {
40 get {
41 return ViewData.Model;
45 [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
46 public new ViewDataDictionary<TModel> ViewData {
47 get {
48 EnsureViewData();
49 return _viewData;
51 set {
52 SetViewData(value);
56 protected override void SetViewData(ViewDataDictionary viewData) {
57 _viewData = new ViewDataDictionary<TModel>(viewData);
59 base.SetViewData(_viewData);