Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1845
Add css class using MVC helper
posted

How do you add a css class using an Infragistics MVC Helper?  I see there are no htmlAttribute parameters like the standard MVC Helpers.  I tried using the Infragistics model's HtmlAttribute property, but it isn't adding any css classes to the rendered control.  Here's whate I've tried:

http://pastebin.com/Bc20Gni4

  • 24497
    Verified Answer
    posted

    Hi Josh,

    It was not clear to me how to test your sample, so, I tried following:
    1.
    Model:
     public TextEditorModel TextEditor1
     {
      get
      {
       TextEditorModel tm = new TextEditorModel();
       tm.HtmlAttributes = new Dictionary<string, object>();
       tm.HtmlAttributes.Add("class", "ok");
       return tm;
      }
     }

    VIew:
    <%= Html.Infragistics().TextEditor(Model.TextEditor1) %>

    2.
    View:
    <%
     Dictionary<string, object> attr = new Dictionary<string, object>();
     attr.Add("class", "ok");
    %>
    <%= Html.Infragistics().TextEditor().HtmlAttributes(attr).Render() %>

    Output was following (skipping javascript and hidden field):
    Generated html:
    <input class="ok" id="TextEditor1">...
    <input class="ok" id="TextEditor2">...

    Actual DOM:
    <input class="ui-igedit-field ok ui-igedit ui-state-default ui-widget ui-corner-all" id="TextEditor1" style="display: inline-block;"/> ...
    <input class="ui-igedit-field ok ui-igedit ui-state-default ui-widget ui-corner-all" id="TextEditor2" style="display: inline-block;"/> ...

    As you can see the class "ok" was correctly rendered to html.
    Please try to test something like that and check generated html and inspect actual DOM objects.

    Let me know it that will not work.