diff --git a/src/Skybrud.Umbraco.GridData/Extensions/TypedGridExtensionMethods.Controls.cs b/src/Skybrud.Umbraco.GridData/Extensions/TypedGridExtensionMethods.Controls.cs new file mode 100644 index 0000000..6bbeb12 --- /dev/null +++ b/src/Skybrud.Umbraco.GridData/Extensions/TypedGridExtensionMethods.Controls.cs @@ -0,0 +1,36 @@ +using System.Web; +using System.Web.Mvc; + +namespace Skybrud.Umbraco.GridData.Extensions { + + /// + /// Class holding various extension methods for using the typed Grid. + /// + public static partial class TypedGridExtensionMethods { + + /// + /// Gets the HTML of the specified . + /// + /// The instance of used for rendering the control. + /// The control to be rendered. + /// An instance of . + public static HtmlString RenderGridControl(this HtmlHelper helper, GridControl control) { + if (helper == null || control == null) return new HtmlString(""); + return control.GetHtml(helper); + } + + /// + /// Gets the HTML of the specified . + /// + /// The instance of used for rendering the control. + /// The control to be rendered. + /// The partial view to be used for the rendering. + /// An instance of . + public static HtmlString RenderGridControl(this HtmlHelper helper, GridControl control, string partial) { + if (helper == null || control == null) return new HtmlString(""); + return control.GetHtml(helper, partial); + } + + } + +} \ No newline at end of file diff --git a/src/Skybrud.Umbraco.GridData/Extensions/TypedGridExtensionMethods.Rows.cs b/src/Skybrud.Umbraco.GridData/Extensions/TypedGridExtensionMethods.Rows.cs new file mode 100644 index 0000000..d982914 --- /dev/null +++ b/src/Skybrud.Umbraco.GridData/Extensions/TypedGridExtensionMethods.Rows.cs @@ -0,0 +1,36 @@ +using System.Web; +using System.Web.Mvc; + +namespace Skybrud.Umbraco.GridData.Extensions { + + /// + /// Class holding various extension methods for using the typed Grid. + /// + public static partial class TypedGridExtensionMethods { + + /// + /// Gets the HTML of the specified . + /// + /// The instance of used for rendering the row. + /// The row to be rendered. + /// An instance of . + public static HtmlString RenderGridRow(this HtmlHelper helper, GridRow row) { + if (helper == null || row == null) return new HtmlString(""); + return row.GetHtml(helper); + } + + /// + /// Gets the HTML of the specified . + /// + /// The instance of used for rendering the row. + /// The row to be rendered. + /// The partial view to be used for the rendering. + /// An instance of . + public static HtmlString RenderGridRow(this HtmlHelper helper, GridRow row, string partial) { + if (helper == null || row == null) return new HtmlString(""); + return row.GetHtml(helper, partial); + } + + } + +} \ No newline at end of file diff --git a/src/Skybrud.Umbraco.GridData/Extensions/TypedGridExtensionMethods.cs b/src/Skybrud.Umbraco.GridData/Extensions/TypedGridExtensionMethods.cs index 9cc2a04..dac3dae 100644 --- a/src/Skybrud.Umbraco.GridData/Extensions/TypedGridExtensionMethods.cs +++ b/src/Skybrud.Umbraco.GridData/Extensions/TypedGridExtensionMethods.cs @@ -10,7 +10,7 @@ namespace Skybrud.Umbraco.GridData.Extensions { /// /// Class holding various extension methods for using the typed Grid. /// - public static class TypedGridExtensionMethods { + public static partial class TypedGridExtensionMethods { #region Constants diff --git a/src/Skybrud.Umbraco.GridData/GridControl.cs b/src/Skybrud.Umbraco.GridData/GridControl.cs index c9fbe82..2c06aee 100644 --- a/src/Skybrud.Umbraco.GridData/GridControl.cs +++ b/src/Skybrud.Umbraco.GridData/GridControl.cs @@ -1,4 +1,5 @@ using System; +using System.Text.RegularExpressions; using System.Web; using System.Web.Mvc; using System.Web.Mvc.Html; @@ -104,14 +105,11 @@ public HtmlString GetHtml(HtmlHelper helper, string partial) { // If the wrapper is NULL, we shouldn't render the control if (wrapper == null) return new HtmlString(""); - // Prepend the path to the "Controls" folder if not already specified - if (!partial.StartsWith("~/") && !partial.StartsWith("~/")) { - partial = "~/Views/Partials/TypedGrid/Controls/" + partial; + // Prepend the path to the "Editors" folder if not already specified + if (Regex.IsMatch(partial, "^[a-zA-Z0-9-_]+$")) { + partial = "TypedGrid/Editors/" + partial; } - // Append the ".cshtml" extension if not already specified - if (!partial.EndsWith(".cshtml")) partial += ".cshtml"; - // Render the partial view return helper.Partial(partial, wrapper); diff --git a/src/Skybrud.Umbraco.GridData/GridRow.cs b/src/Skybrud.Umbraco.GridData/GridRow.cs index 8a14744..2f70be4 100644 --- a/src/Skybrud.Umbraco.GridData/GridRow.cs +++ b/src/Skybrud.Umbraco.GridData/GridRow.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using System.Text.RegularExpressions; using System.Web; using System.Web.Mvc; using System.Web.Mvc.Html; @@ -161,13 +162,10 @@ public HtmlString GetHtml(HtmlHelper helper, string partial) { if (String.IsNullOrWhiteSpace(partial)) throw new ArgumentNullException("partial"); // Prepend the path to the "Rows" folder if not already specified - if (!partial.StartsWith("~/") && !partial.StartsWith("~/")) { - partial = "~/Views/Partials/TypedGrid/Rows/" + partial; + if (Regex.IsMatch(partial, "^[a-zA-Z0-9-_]+$")) { + partial = "TypedGrid/Rows/" + partial; } - // Append the ".cshtml" extension if not already specified - if (!partial.EndsWith(".cshtml")) partial += ".cshtml"; - // Render the partial view return helper.Partial(partial, this); diff --git a/src/Skybrud.Umbraco.GridData/Skybrud.Umbraco.GridData.csproj b/src/Skybrud.Umbraco.GridData/Skybrud.Umbraco.GridData.csproj index d6d8c83..7f134cf 100644 --- a/src/Skybrud.Umbraco.GridData/Skybrud.Umbraco.GridData.csproj +++ b/src/Skybrud.Umbraco.GridData/Skybrud.Umbraco.GridData.csproj @@ -282,6 +282,8 @@ + +