Document.getElementById("C1") is null

Error: document.getElementById(“C1”) is null
Source File: http://localhost:2276/main.aspx
Line: 34

i am getting this error the same script was working fine yest
but now i get the above error

on window.load function

how do i trace for error

You do keep backups don’t you? Or even better, use some form of version control?

Go back to the code that worked yesterday, and work forward through that changes that have since been made, testing until you narrow down what caused the problem.

that i have already started
but just wanted to know abt this error & ways to solve it so that its useful in future

Given that it previously worked, it means that the element that used to have an id of “C1” on it is now no longer available.

There can be a few different reasons why this might occur:

  1. The element used to be there but has now been removed
  2. Something has happened to cause the element to be added to the page later than the code which needs to access it
  3. The code that needs to access the element runs before the element has been created

How I would approach this is to set a breakpoint on the offending line, and investigate the HTML and scripting code to find out what clues might be divulged from such an investigation.

i am not sure abt the reason
but i have a grid on the page if i set the autopost back property of the grrid to true i get the above error