本文整理汇总了C#中System.Web.Mvc.ActionResult.GetT4MVCResult方法的典型用法代码示例。如果您正苦于以下问题:C# ActionResult.GetT4MVCResult方法的具体用法?C# ActionResult.GetT4MVCResult怎么用?C# ActionResult.GetT4MVCResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Mvc.ActionResult
的用法示例。
在下文中一共展示了ActionResult.GetT4MVCResult方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeActiveClass
public static string MakeActiveClass(this UrlHelper urlHelper, ActionResult controller)
{
string result = null;
if (
(controller.GetT4MVCResult().Controller == urlHelper.RequestContext.RouteData.Values["controller"].ToString()) &&
(controller.GetT4MVCResult().Action == urlHelper.RequestContext.RouteData.Values["action"].ToString())
)
{
result = "active";;
}
return result;
}
示例2: NavActionLink
/// <summary>
/// Creates a Navigation action link inside an li tag that highlights based on which page you're on.
/// </summary>
/// <param name="htmlHelper">The HTML helper.</param>
/// <param name="linkText">The link text.</param>
/// <param name="actionResult">The action result.</param>
/// <returns></returns>
public static MvcHtmlString NavActionLink(this HtmlHelper htmlHelper, string linkText, ActionResult actionResult)
{
var result = actionResult.GetT4MVCResult();
var li = new TagBuilder("li");
// create anchor tag
var anchor = HtmlHelper.GenerateLink(
htmlHelper.ViewContext.RequestContext,
RouteTable.Routes,
linkText,
"",
result.Action,
result.Controller,
result.RouteValueDictionary,
null);
// add anchor tag to li tag
li.InnerHtml = anchor;
// get the route data
var controller = htmlHelper.ViewContext.Controller.ValueProvider.GetValue("controller").RawValue as string;
var action = htmlHelper.ViewContext.Controller.ValueProvider.GetValue("action").RawValue as string;
if (result.Action == action && result.Controller == controller)
{
li.MergeAttribute("class", "active");
}
return MvcHtmlString.Create(li.ToString());
}
示例3: RedirectToLocal
public static ActionResult RedirectToLocal(this Controller controller, ActionResult action)
{
if (action != null && controller.Url.IsLocalUrl(controller.Url.Action(action)))
return new RedirectToRouteResult(action.GetT4MVCResult().RouteValueDictionary);
return new RedirectToRouteResult(MVC.Home.Index().GetT4MVCResult().RouteValueDictionary);
}
示例4: RedirectToAction
public static ActionResult RedirectToAction(this Controller controller, ActionResult result, string urlFragment)
{
var callInfo = result.GetT4MVCResult();
if (!string.IsNullOrWhiteSpace(urlFragment))
{
var url = UrlHelper.GenerateUrl(null, null, null, callInfo.RouteValueDictionary, RouteTable.Routes, controller.HttpContext.Request.RequestContext, false);
url = string.Concat(url, "#", urlFragment);
return new RedirectResult(url, false);
}
else
{
return new RedirectToRouteResult(callInfo.RouteValueDictionary);
}
}
示例5: RedirectToActionPermanent
protected RedirectToRouteResult RedirectToActionPermanent(ActionResult result)
{
var callInfo = result.GetT4MVCResult();
return RedirectToRoutePermanent(callInfo.RouteValueDictionary);
}
示例6: BeginForm
public static MvcForm BeginForm(this HtmlHelper htmlHelper, ActionResult result, FormMethod formMethod, IDictionary<string, object> htmlAttributes)
{
var callInfo = result.GetT4MVCResult();
return htmlHelper.BeginForm(callInfo.Action, callInfo.Controller, callInfo.RouteValueDictionary, formMethod, htmlAttributes);
}
示例7: ActionLink
public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, ActionResult result, IDictionary<string, object> htmlAttributes, string protocol, string hostName, string fragment)
{
return htmlHelper.RouteLink(linkText, null, protocol ?? result.GetT4MVCResult().Protocol, hostName, fragment, result.GetRouteValueDictionary(), htmlAttributes);
}
示例8: Action
public static string Action(this UrlHelper urlHelper, ActionResult result, string protocol = null, string hostName = null)
{
return urlHelper.RouteUrl(null, result.GetRouteValueDictionary(), protocol ?? result.GetT4MVCResult().Protocol, hostName);
}
示例9: RenderAction
public static void RenderAction(this HtmlHelper htmlHelper, ActionResult result)
{
var callInfo = result.GetT4MVCResult();
htmlHelper.RenderAction(callInfo.Action, callInfo.Controller, callInfo.RouteValueDictionary);
}
示例10: ActionLink
public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, ActionResult result, object htmlAttributes, string protocol = null, string hostName = null, string fragment = null) {
return htmlHelper.RouteLink(linkText, null, protocol ?? result.GetT4MVCResult().Protocol, hostName, fragment, result.GetRouteValueDictionary(), HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));
}
示例11: RouteUrl
public static string RouteUrl(this UrlHelper urlHelper, string routeName, ActionResult result, string protocol, string hostName)
{
return urlHelper.RouteUrl(routeName, result.GetRouteValueDictionary(), protocol ?? result.GetT4MVCResult().Protocol, hostName);
}
示例12: BeginActionLink
/// <summary>
/// Begins a new action link. For use in a using statement, allowing other code inside the tag.
/// </summary>
/// <param name="htmlHelper">The class being extended with this method.</param>
/// <param name="result">An IT4MVCActionResult from a T4 MVC action method used to help build urls.</param>
/// <param name="htmlAttributes">A dictionary with name and value pairs.</param>
/// <returns></returns>
public static MvcTag BeginActionLink(this HtmlHelper htmlHelper, ActionResult result, IDictionary<string, object> htmlAttributes)
{
var callInfo = result.GetT4MVCResult();
return htmlHelper.BeginActionLink(callInfo.Action, callInfo.Controller, callInfo.RouteValueDictionary, htmlAttributes);
}
示例13: ActionImageTag
/// <summary>
/// Generates an anchor tag (link) with an image inside such that the image when clicked follows the specified MVC route.
/// </summary>
/// <param name="helper">The class being extended with this method.</param>
/// <param name="result">An IT4MVCActionResult from a T4 MVC action method used to help build urls.</param>
/// <param name="imageFileName">The file name of the image including full relative path. Recommend coming from T4MVC Links property.</param>
/// <param name="anchorHtmlAttributes">A dynamic object with name and value pairs for the anchor tag. Example: new {data-custom1="abc", @class="large"}</param>
/// <param name="imageHtmlAttributes">A dynamic object with name and value pairs for the image tag. Example: new {data-custom1="abc", @class="large"}</param>
/// <returns></returns>
public static MvcHtmlString ActionImageTag(this HtmlHelper helper, ActionResult result, string imageFileName, object anchorHtmlAttributes, object imageHtmlAttributes)
{
IT4MVCActionResult t4 = result.GetT4MVCResult();
return ActionImageTag(helper, t4.Action, t4.Controller, imageFileName, t4.RouteValueDictionary, anchorHtmlAttributes, imageHtmlAttributes);
}