Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Want to add Html Attributes classes at run time

Want to add Html Attributes classes at run time

Scheduled Pinned Locked Moved ASP.NET
helpjavascripthtmlasp-netcom
1 Posts 1 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    indian143
    wrote on last edited by
    #1

    Hi, I have a Kendo text box @Html.Kendo().TextBoxFor(model => model.Code).Name("txtForCode").HtmlAttributes(new { autocomplete = "off", id = "idTxtForCode" }), I am able to add class static without any problem, but I want to add different classes at runtime using a JavaScript if else conditions. Just like in the below Code;

    function GetLookupTableValue(e)
    {
        var noCodeFilter = containsAny($("#drpLookup").data("kendoDropDownList").text(), \['Address Type', 'Gender', 'NPI Status', 'Rendering Provider Status', 'Rendering Provider Classification'\]);
        
        if (noCodeFilter)
        {
            var url = '../Admin/GetLookupTableNoCode';
            $("#divLookupTable").load(url, { LookupTableId: $("#drpLookup").data("kendoDropDownList").value() });
        }
        else
        {
            var url = '../Admin/GetLookupTableCode';
            $("#divLookupTable").load(url, { LookupTableId: $("#drpLookup").data("kendoDropDownList").value() });
    
            /\*like here I want to add condition that if the containsAny($("#drpLookup").data("kendoDropDownList").text(), \['Provider Type', 'X type', 'some other type'\])
               then txtForCode should accept only two digits
             else if dropdown drpLookup contains text from \['xxx', 'yyy', 'zzzz'\] then txtForCode should accept only 3 digits
             else if dropdown drpLookup contains text from \['aaa', 'bbb', 'ccc'\] then txtForCode should accept only 2 character capitals
             else if dropdown drpLookup contains text from \['ccc', 'ddd', 'eee'\] then txtForCode should accept only 5 character capitals
             else if dropdown drpLookup contains text from \['fff', 'ggg', 'hhh'\] then txtForCode should accept only 8 character capitals
             else default condition \*/
        }
    }
    

    Can anybody please help me with this, one way to add HtmlAttributes to the MVC Kendo Textbox is using HtmlAttributes, but it sets statically at one time but I want to change the classes run-time depending upon the dropdown selection. Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups