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. Setting onblur, onkeyup and onkeydown for @Html.Kendo().TextBoxFor using HtmlAttributes

Setting onblur, onkeyup and onkeydown for @Html.Kendo().TextBoxFor using HtmlAttributes

Scheduled Pinned Locked Moved ASP.NET
javascripthtmlcomdebugginghelp
3 Posts 2 Posters 12 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 all friends, I have a textbox like below, I want call jquery function on its onblur or onkeyup or onfocus etc. @Html.Kendo().TextBoxFor(model => model.Code).HtmlAttributes(new { autocomplete = "off", id = "idTxtForCodeLookupCode" }) when I set it as $("#idTxtForCodeLookupCode").on('input', function () { debugger; SetLookupTableValue(); }); function SetLookupTableValue() { $("#txtLookupTableId").val($("#drpLookup").data("kendoDropDownList").value()); $("#txtLookupTableId").val(); } The SetLookupTableValue() function is not being called. I don't know the reason, maybe because TextBox is in Popup and the functions are in the main page. But I want to try it it works it I can set this onblur event or keyup or even onfocus events using HtmlAttributes, it might work. Can anybody please help me how to set those events using HtmlAttributes property. Any help would be very helpful, thanks in advance. Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."

    J 1 Reply Last reply
    0
    • I indian143

      Hi all friends, I have a textbox like below, I want call jquery function on its onblur or onkeyup or onfocus etc. @Html.Kendo().TextBoxFor(model => model.Code).HtmlAttributes(new { autocomplete = "off", id = "idTxtForCodeLookupCode" }) when I set it as $("#idTxtForCodeLookupCode").on('input', function () { debugger; SetLookupTableValue(); }); function SetLookupTableValue() { $("#txtLookupTableId").val($("#drpLookup").data("kendoDropDownList").value()); $("#txtLookupTableId").val(); } The SetLookupTableValue() function is not being called. I don't know the reason, maybe because TextBox is in Popup and the functions are in the main page. But I want to try it it works it I can set this onblur event or keyup or even onfocus events using HtmlAttributes, it might work. Can anybody please help me how to set those events using HtmlAttributes property. Any help would be very helpful, thanks in advance. Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."

      J Offline
      J Offline
      jkirkerx
      wrote on last edited by
      #2

      Depends on the version of JQuery your using. The call changes as versions are updated. Technically, JQuery can select an element anywhere on the page or in the DOM, even if it's hidden. Best thing to do is test first. just have the function write an alert to see if it works first, then write your code to do it's thing.

      $("#idTxtForCodeLookupCode").on('blur', function ()

      $("#idTxtForCodeLookupCode").blur(function() {

      focus, blur, keyup is very tricky and requires more code to listen to certain keys. I'm going to a seminar, the post JQuery world, in which basically JQuery is no longer needed with modern JavaScript and TypeScript being available now. Something for us to think about.

      If it ain't broke don't fix it Discover my world at jkirkerx.com

      J 1 Reply Last reply
      0
      • J jkirkerx

        Depends on the version of JQuery your using. The call changes as versions are updated. Technically, JQuery can select an element anywhere on the page or in the DOM, even if it's hidden. Best thing to do is test first. just have the function write an alert to see if it works first, then write your code to do it's thing.

        $("#idTxtForCodeLookupCode").on('blur', function ()

        $("#idTxtForCodeLookupCode").blur(function() {

        focus, blur, keyup is very tricky and requires more code to listen to certain keys. I'm going to a seminar, the post JQuery world, in which basically JQuery is no longer needed with modern JavaScript and TypeScript being available now. Something for us to think about.

        If it ain't broke don't fix it Discover my world at jkirkerx.com

        J Offline
        J Offline
        jkirkerx
        wrote on last edited by
        #3

        The meetup was pretty cool. Technically we don't need JQuery anymore for modern browsers that support HTML5, because modern JavaScript is now part of the browser. You save a 2 meg download on pages that use JQuery. There are many small npm libraries like animate.css that are around 64K in size that can do animation for you and Ajax is built in now.

        If it ain't broke don't fix it Discover my world at jkirkerx.com

        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