Robię rozszerzenie.htmlAtagi nie łączą się z konstruktorem tagów w moim rozszerzeniu
public static MvcHtmlString Image(this HtmlHelper helper, string src, object htmlAttributes = null)
{
TagBuilder builder = new TagBuilder("img");
builder.MergeAttribute("src", src);
if (htmlAttributes != null) builder.MergeAttributes(htmlAttributes);
return MvcHtmlString.Create(builder.ToString(TagRenderMode.SelfClosing));
}
tej linii:
if (htmlAttributes != null) builder.MergeAttributes(htmlAttributes);
Błędy z:
The type arguments for method 'System.Web.Mvc.TagBuilder.MergeAttributes<TKey,TValue>(System.Collections.Generic.IDictionary<TKey,TValue>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
próbowałem:
if (htmlAttributes != null) builder.MergeAttributes((Dictionary<string, string>)htmlAttributes);
i
if (htmlAttributes != null) builder.MergeAttributes((Dictionary<string, object>)htmlAttributes);
Jak mogę to uruchomić?
to było dla mnie bardzo pomocne - rozglądałem się za czymś takim. –