Hi all
I have a Html helper method with the following signature:
public static string MyActionLink(this HtmlHelper html
, string linkText
, List<KeyValuePair<string, object>> attributePairs
, bool adminLink){}
I have another utility then that takes all the attribute pairs and merges them to the tag as attribute/value pairs:
ExtensionsUtilities.MergeAttributesToTag(tag, attributePairs);
and everything is fine. The problem, however, is that the parameter
, List<KeyValuePair<string, object>> attributePairs
is a bit cumbersome in the definition, and even moreso in the use of the Helper method:
<span class="MySpan">
<%= Html.MyActionLink(Html.Encode(item.Name)
, new List<KeyValuePair<string, object>>
{
Html.GetAttributePair("href", Url.Action("ACTION","CONTROLLER")),
Html.GetAttributePair("Id", Html.Encode(item.Id)),
Html.GetAttributePair("customAttribute1", Html.Encode(item.Val1)),
Html.GetAttributePair("customAttribute2", Html.Encode(item.Val2))
}, false)%>
</span>
(Html.GetAttributePair()
just returns a KeyValuePair in an attempt to tidy things a bit)
I'm just curious now if somebody could suggest a different (maybe more efficient & developer-friendly) approach to acheiving the same result?
Thanks Guys
Dave