user2593100
user2593100

Reputation: 23

Uncaught TypeError: Cannot set property of null

I keep on getting "Uncaught TypeError: Cannot set property of null" whenever my code hits the js code below to open a popup when clicked on a label on aspx page. Please help.

function openWindow(which) {
            //alert(which);
            //alert(document.getElementById('iframeClass').src);
            document.getElementById('iframeClass').src = 'ViewIovationResults.aspx?ordernumber=' + which;

            //alert(document.getElementById('iframeClass').src);
                if (divMap.style["display"] == "none") {
                divMap.style["display"] = "";

            }
        }

    <tr>
        <td width="190"><STRONG>Order Number :</STRONG></td>                                                                    <td width="200">                                                                <a  onclick="javascript:openWindow('<%# DataBinder.Eval(Container.DataItem, "Order Number") %>')"><%# DataBinder.Eval(Container.DataItem, "Order Number") %></a>                                                          </td>
    </tr>

Upvotes: 1

Views: 14029

Answers (3)

Sergio
Sergio

Reputation: 28837

You should have inside the function var divMap = document.getElementById('divMap '); before calling it. Unless its defined already outside the function and within scope.

Upvotes: 1

Karl Anderson
Karl Anderson

Reputation: 34846

My guess is that you do not have an element on your page with an ID value of iframeClass. Verify the name of this element or there is no variable named divMap.

Upvotes: 0

Claudio Redi
Claudio Redi

Reputation: 68400

Without more information is hard to say, but if that's the problematic code then, by the time that script is executed, there is no element with id iframeClass or/and divMap is null.

So In short:

  • Do you have an html element with id iframeClass?
  • Do you have an html element with id divMap?
  • If both elements exist on the page, are you executing that script after they are loaded?

Upvotes: 1

Related Questions