Click or drag to resize

HTMLButtonByAction Method

Generate HTML code for Botton with syntax: href="@Url.Action(Action, Controller, Value)"

Namespace:  SOWIWeb.Helper
Assembly:  SOWIWeb.Helper (in SOWIWeb.Helper.dll) Version: 19.1.23.1 (19.1.23.622)
Syntax
public static string ButtonByAction(
	string pController,
	string pAction,
	Object pValue,
	string pIcon,
	string pLabel,
	bool pDisabled = false,
	string pStyle = "btn btn-default",
	string pTooltipText = "",
	DataPlacements pTooltipPlacement = DataPlacements.bottom
)

Parameters

pController
Type: SystemString
pAction
Type: SystemString
pValue
Type: SystemObject
e.g. new { id = item.ID }
pIcon
Type: SystemString
e.g. glyphicon glyphicon-pencil
pLabel
Type: SystemString
pDisabled (Optional)
Type: SystemBoolean
pStyle (Optional)
Type: SystemString
default: btn btn-default | btn-block (span the full width of a parent) | sizes: btn-lg, btn-sm, btn-xs
pTooltipText (Optional)
Type: SystemString
help text use on editor object tooltip
pTooltipPlacement (Optional)
Type: SOWIWeb.HelperDataPlacements
tooltip placement (default bottom)

Return Value

Type: String

[Missing <returns> documentation for "M:SOWIWeb.Helper.HTML.ButtonByAction(System.String,System.String,System.Object,System.String,System.String,System.Boolean,System.String,System.String,SOWIWeb.Helper.DataPlacements)"]

Examples
Use simple ButtonByAction in a cshtml file as table button for data item edit
<div class="table-btn print-none">
   @Html.Raw(SOWIWeb.Helper.HTML.ButtonByAction("QualiTemplateCriterion", "Edit", new { id = item.ID }, "glyphicon glyphicon-pencil", "", false, "btn btn-xs"))
</div>
Use ButtonByAction example web standard controller action Index Toolbar items. See method IndexGetToolbarItem
protected virtual List<SOWIWeb.Helper.ToolbarButton> IndexGetToolbarItem()
{
    var lToolbar = new List<SOWIWeb.Helper.ToolbarButton>();
    lToolbar.Add(new SOWIWeb.Helper.ToolbarButton(this.ControllerName, SOWIWeb.Helper.ToolbarButtonsIndex.Edit.ToString(), "glyphicon glyphicon-pencil", "", !this.CanEdit));
    lToolbar.Add(new SOWIWeb.Helper.ToolbarButton(this.ControllerName, SOWIWeb.Helper.ToolbarButtonsIndex.Details.ToString(), "glyphicon glyphicon-folder-open", "", !this.CanDetails));
    lToolbar.Add(new SOWIWeb.Helper.ToolbarButton(this.ControllerName, SOWIWeb.Helper.ToolbarButtonsIndex.Delete.ToString(), "glyphicon glyphicon-trash", "", !this.CanDelete));
    return lToolbar;
}
Method ButtonByAction gives HTML code e.g.
<a class="btn btn-default" href="@Url.Action("Edit", lControllerName, new { id = item.ID })" role="button"><span class="glyphicon glyphicon-pencil"></span></a>
<a class="btn btn-default" href="@Url.Action("Details", lControllerName, new { id = item.ID })" role="button"><span class="glyphicon glyphicon-folder-open"></span></a>
<a class="btn btn-default" href="@Url.Action("Delete", lControllerName, new { id = item.ID })" role="button"><span class="glyphicon glyphicon-trash"></span></a>
See Also