We have some pages (lets call it parent pages) that calls to other .aspx (lets call it child pages) using RenderAction.
What i would like to do is use in these parent pages some kind of helper that prints the name of these child pages if in the querystring appears debug=1 using something like:
@Html.AutodiscoverWidgets()
Its possible to do this? I would like to avoid put in every child page something like:
@Html.AutodiscoverWidgets("NameOfTheChildView")
What i have by the moment is the following extension method:
public static MvcHtmlString AutodiscoverWidgets(this HtmlHelper htmlHelper)
{
if (HttpContext.Current.Request.QueryString["debug"].ToString() == "1")
{
return MvcHtmlString.Create("hello");
}
else
{
return MvcHtmlString.Create("");
}
}
You could use the following helper:
and then: