New test.
[mono.git] / mcs / class / System.Web.Mvc2 / System.Web.Mvc / Html / PartialExtensions.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.Html {\r
14     using System.Globalization;\r
15     using System.IO;\r
16 \r
17     public static class PartialExtensions {\r
18         public static MvcHtmlString Partial(this HtmlHelper htmlHelper, string partialViewName) {\r
19             return Partial(htmlHelper, partialViewName, null /* model */, htmlHelper.ViewData);\r
20         }\r
21 \r
22         public static MvcHtmlString Partial(this HtmlHelper htmlHelper, string partialViewName, ViewDataDictionary viewData) {\r
23             return Partial(htmlHelper, partialViewName, null /* model */, viewData);\r
24         }\r
25 \r
26         public static MvcHtmlString Partial(this HtmlHelper htmlHelper, string partialViewName, object model) {\r
27             return Partial(htmlHelper, partialViewName, model, htmlHelper.ViewData);\r
28         }\r
29 \r
30         public static MvcHtmlString Partial(this HtmlHelper htmlHelper, string partialViewName, object model, ViewDataDictionary viewData) {\r
31             StringWriter writer = new StringWriter(CultureInfo.CurrentCulture);\r
32             htmlHelper.RenderPartialInternal(partialViewName, viewData, model, writer, ViewEngines.Engines);\r
33             return MvcHtmlString.Create(writer.ToString());\r
34         }\r
35     }\r
36 }\r