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. javascript __dopostback System.NullReferenceException

javascript __dopostback System.NullReferenceException

Scheduled Pinned Locked Moved ASP.NET
helpjavascriptcsstools
6 Posts 2 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.
  • J Offline
    J Offline
    jojoba2011
    wrote on last edited by
    #1

    Here's the problem : When the gvWorkReportList is invisble and gvWorkReportList.FooterRow =null in page loading i get the bellow error :

    Quote:

    System.NullReferenceException: Object reference not set to an instance of an object. the error is on this part of code : __doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');

    Quote:

    this is the piece of my code!

    <script type="text/javascript">

        function KeyDownHandler() {
    
            // process only the Enter key
            if (event.keyCode == 13) {
                 
                    \_\_doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');
    
                
            }
        }
    
    </script>
    

    This doesn't seem like it should be that hard, so if someone could just give me a kick in the right direction, that'd be awesome. I have used these solution but it dosen't work :

    var grid = document.getElementById('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>');
    if (grid != null) {
    __doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');

                }
    

    var grid = document.getElementById("ctl00_ContentPlaceHolderContent_gvWorkReportList");
    if (grid != null) {
    __doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');

                }
    

    var gridFooter = gvWorkReportList.FooterRow;
    if (gridFooter != null) {
    __doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');

                }
    
    K J 2 Replies Last reply
    0
    • J jojoba2011

      Here's the problem : When the gvWorkReportList is invisble and gvWorkReportList.FooterRow =null in page loading i get the bellow error :

      Quote:

      System.NullReferenceException: Object reference not set to an instance of an object. the error is on this part of code : __doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');

      Quote:

      this is the piece of my code!

      <script type="text/javascript">

          function KeyDownHandler() {
      
              // process only the Enter key
              if (event.keyCode == 13) {
                   
                      \_\_doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');
      
                  
              }
          }
      
      </script>
      

      This doesn't seem like it should be that hard, so if someone could just give me a kick in the right direction, that'd be awesome. I have used these solution but it dosen't work :

      var grid = document.getElementById('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>');
      if (grid != null) {
      __doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');

                  }
      

      var grid = document.getElementById("ctl00_ContentPlaceHolderContent_gvWorkReportList");
      if (grid != null) {
      __doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');

                  }
      

      var gridFooter = gvWorkReportList.FooterRow;
      if (gridFooter != null) {
      __doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');

                  }
      
      K Offline
      K Offline
      Karthik Harve
      wrote on last edited by
      #2

      Hi, if the gridview is invisible i.e. you have made visible = "false", the control will not be rendered into the client, and object will go null. So, this is what happening in your case. if you want the gridview to be rendered into the client but not to be displayed, then try by using style attribute like this. style = "display: none;". if you do so, probably you can access UniqueID. hope it helps.

      Vande Matharam - Jai Hind

      J 1 Reply Last reply
      0
      • K Karthik Harve

        Hi, if the gridview is invisible i.e. you have made visible = "false", the control will not be rendered into the client, and object will go null. So, this is what happening in your case. if you want the gridview to be rendered into the client but not to be displayed, then try by using style attribute like this. style = "display: none;". if you do so, probably you can access UniqueID. hope it helps.

        Vande Matharam - Jai Hind

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

        thanks for solution. But i dont need to get access when it is invisible. How i can control it if gridview in invisible the the code

        __doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');

        doesnt run. Thanks in advanced!

        K 1 Reply Last reply
        0
        • J jojoba2011

          thanks for solution. But i dont need to get access when it is invisible. How i can control it if gridview in invisible the the code

          __doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');

          doesnt run. Thanks in advanced!

          K Offline
          K Offline
          Karthik Harve
          wrote on last edited by
          #4

          Hi, try like below.

          var grid = document.getElementById('<%=gvWorkReportList.ClientID%>');
          if (grid != null) {
          __doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');
          }

          hope it works.

          Vande Matharam - Jai Hind

          J 1 Reply Last reply
          0
          • K Karthik Harve

            Hi, try like below.

            var grid = document.getElementById('<%=gvWorkReportList.ClientID%>');
            if (grid != null) {
            __doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');
            }

            hope it works.

            Vande Matharam - Jai Hind

            J Offline
            J Offline
            jojoba2011
            wrote on last edited by
            #5

            not used! Cause :

            var grid = document.getElementById('<%=gvWorkReportList.ClientID%>');

            is not null . but this code :

            gvWorkReportList.FooterRow

            is null. Thnaks in advanced!

            1 Reply Last reply
            0
            • J jojoba2011

              Here's the problem : When the gvWorkReportList is invisble and gvWorkReportList.FooterRow =null in page loading i get the bellow error :

              Quote:

              System.NullReferenceException: Object reference not set to an instance of an object. the error is on this part of code : __doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');

              Quote:

              this is the piece of my code!

              <script type="text/javascript">

                  function KeyDownHandler() {
              
                      // process only the Enter key
                      if (event.keyCode == 13) {
                           
                              \_\_doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');
              
                          
                      }
                  }
              
              </script>
              

              This doesn't seem like it should be that hard, so if someone could just give me a kick in the right direction, that'd be awesome. I have used these solution but it dosen't work :

              var grid = document.getElementById('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>');
              if (grid != null) {
              __doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');

                          }
              

              var grid = document.getElementById("ctl00_ContentPlaceHolderContent_gvWorkReportList");
              if (grid != null) {
              __doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');

                          }
              

              var gridFooter = gvWorkReportList.FooterRow;
              if (gridFooter != null) {
              __doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');

                          }
              
              J Offline
              J Offline
              jojoba2011
              wrote on last edited by
              #6

              Quote:

              **_This doesn't seem like it should be that hard, so if someone could just give me a kick in the right direction, that'd be awesome._**

              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