Uzantı yapıyorum. Ben denedimhtmlAtributes, uzantılamamda etiket oluşturucu ile birleşmiyor
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.
:
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)); }
Bu hat: ile if (htmlAttributes != null) builder.MergeAttributes(htmlAttributes);
Hatalar
if (htmlAttributes != null) builder.MergeAttributes((Dictionary<string, string>)htmlAttributes);
ve
if (htmlAttributes != null) builder.MergeAttributes((Dictionary<string, object>)htmlAttributes);
Bunu nasıl çalıştırabilirim?
bu bana gerçekten yardımcı oldu - Bu gibi şeyler için etrafa baktım. –