javascript not recognising server variable problem

Discussion in 'ASP.NET 2.0' started by equistarco1, Sep 24, 2009.

  1. Hi,
    I've just uploaded my site, but get the following error.
    Object reference not set to an instance of an object.

    function CheckCloseRefresh()
    Line 49: {
    Line 50: if (<%= Show %> == true)Line 51: {
    Line 52: Login();

    I've checked, the upload is correct, and this does run on my Dev machine.
    Anybody know why or how to resolve it.

    Many Thanks
    Neal
     
  2. Hi re my prior post/question..
    Could this be because all machines I've tested on XpPro PC and Laptop and Windows 2000 server are using IIS 5.something and possibly the host servers are IIS 7????
    thus requiring changes in the WebConfig?

    TIA
    Neal
     
  3. Embedded server vars in java script contd.

    To add to the above.

    I opted for 2003 server hosting (IIS 6) , not IIS 7.

    I specified using my own domain. (if that makes a difference?? DNS and I are not at all acquainted).

    But on XP pro (or windows server 2000) and IIS 5 the wen app runs. I do use Telerik RadAjaxControls.

    May be I need to make changes to my Config file?

    Bit tense as this site needs to be live by Monday latest.
    TIA
    Neal
     
  4. ...I'll try and help, since you are already a bit tense. ;-)
    In the code you posted there isn't enough to go on.
    If we look above and see "Show" we can not tell if or how it is a variable.
    btw, is this a section of code you wrote or that came in a package?
    I'm asking because doing it that way, in-line, can be written better to trap errors.
    All the best,
    Mark
     
  5. The only reason you'll get an "Object reference is not set to an instance of an object" error is because your variable is null and you're trying access data that doesn't exist. So, if that variables is dependent on something that might be in the machine.config file then that would definitely generate it. Regardless, double/triple/quadruple check how that variables is being instantiated and make sure it has data before you try to use it.
     

Share This Page