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. General Programming
  3. .NET (Core and Framework)
  4. unable to get property 'childnodes' of undefined or null reference

unable to get property 'childnodes' of undefined or null reference

Scheduled Pinned Locked Moved .NET (Core and Framework)
data-structureshelp
3 Posts 3 Posters 0 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.
  • U Offline
    U Offline
    User 10519661
    wrote on last edited by
    #1

    function GetEqrDataUploadFiles()
    {
    var upload=$("#files").data("KendoUpload");
    // in this line Error is coming " Unable to get property 'childNodes' of undefined or null reference "

    var s = upload.wrapper[0].childNodes[2].childNodes.length;

    var a = new Array();
    for (i = 0; i < s; i++)
    {
    if (document.all) {
    a.push(upload.wrapper[0].childNodes[2].childNodes[i].innerText);
    }
    else {
    a.push(upload.wrapper[0].childNodes[2].childNodes[i].textContent);
    }
    }
    return a;
    }

    S J 2 Replies Last reply
    0
    • U User 10519661

      function GetEqrDataUploadFiles()
      {
      var upload=$("#files").data("KendoUpload");
      // in this line Error is coming " Unable to get property 'childNodes' of undefined or null reference "

      var s = upload.wrapper[0].childNodes[2].childNodes.length;

      var a = new Array();
      for (i = 0; i < s; i++)
      {
      if (document.all) {
      a.push(upload.wrapper[0].childNodes[2].childNodes[i].innerText);
      }
      else {
      a.push(upload.wrapper[0].childNodes[2].childNodes[i].textContent);
      }
      }
      return a;
      }

      S Offline
      S Offline
      Simon_Whale
      wrote on last edited by
      #2

      If I'm not mistaken that looks more like Javascript. If so then I think you will get a better answer in this forum Javascript[^]

      Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON

      1 Reply Last reply
      0
      • U User 10519661

        function GetEqrDataUploadFiles()
        {
        var upload=$("#files").data("KendoUpload");
        // in this line Error is coming " Unable to get property 'childNodes' of undefined or null reference "

        var s = upload.wrapper[0].childNodes[2].childNodes.length;

        var a = new Array();
        for (i = 0; i < s; i++)
        {
        if (document.all) {
        a.push(upload.wrapper[0].childNodes[2].childNodes[i].innerText);
        }
        else {
        a.push(upload.wrapper[0].childNodes[2].childNodes[i].textContent);
        }
        }
        return a;
        }

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

        As the previous reply indicated -- this is Javascript -- and it is using -- most likely jQuery. I am responding because -- this snippet is accessing the DOM and making assumptions that are causing it to fail -- without grace and without any real way to provide much information, but -- the exception seems to indicate that the node being accessed is not present. This is not a good way to find the element in question and the code has been written in an odd manner because the author has not taken the time to understand nodes -- if you do not do this, your only options moving forward are to write code like this and hope for the best, or abdicate the responsibility by using a 3rd party client side library for that. To make matters worse, this issue of textContent vs. innerText -- is a well known difference between browsers and how they view whitespace in documents -- particularly XML documents. It behooves a developer to take the responsibility of learning how to walk the DOM themselves and to check for null -- at least once. How do you know where you are in the DOM otherwise? This script -- needs a lot of work to be robust --

        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