I have Javascript code written in an iframe, that is modifying the value of a hiddenfield in a contentplaceholder in parent window, and also firing a click event of a button, and setting the visibility of an iframe. They all are referenced erroneously.
Javascript in iframe:
 <script type="text/javascript">
      function ChangeView(obj) {
          parent.document.getElementById("HiddenField1").value = $(obj).attr('id');
          parent.document.getElementById("Button1").click();
          var iframe = parent.document.getElementById("newsFrame");
          iframe.style.display = "block";
      }
    </script>
</head>
<body>
 <form id="f">
    <nav>
      <ul id="nav">
        <li><a id="aHome"  href="#" onclick="ChangeView(this)" >Home</a></li>   
        <li><a href="#">About</a>
          <ul>
            <li><a id="aMessage" href="#" onclick="ChangeView(this)">Message</a></li>
          </ul>
        </li>
      </ul>
    </nav>
 </form>
</body>
Parent page:
<asp:Content ID="Content3"  ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
   <html xmlns="http://www.w3.org/1999/xhtml" > 
<head>
    <title> </title>
<script runat="server">
    Sub ChangeView()
        Dim t As HiddenField
        ' Dim mc As Control = FindControl("Label1")
        t = FindControl("HiddenField1")
        Dim m As MultiView
        m = FindControl("Multiview1")
        If (t.Value = "aHome") Then
            m.ActiveViewIndex = 0
        End If
        If (t.Value = "aMessage") Then
            m.ActiveViewIndex = 1
        End If
    End Sub
   </script>
</head>
<body>
   <form id="form1" runat="server">
   <asp:Button ID="Button1" runat="server"  Visible="True" OnClick="ChangeView"  />
       <asp:ScriptManager ID="SM1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
        <asp:HiddenField ID="HiddenField2"  runat="server"  />
         <asp:MultiView ID="MultiView2" runat="server" ActiveViewIndex="0">
            <asp:View ID="View8" runat="server">
                This is HOME 
            </asp:View>
            <asp:View ID="View9" runat="server">
                This is DEPARTMENT MESSAGE 
            </asp:View>
        </asp:MultiView>
        <br /><br />
        </ContentTemplate>
    </asp:UpdatePanel>
   </form>
</body>
</html>
                <iframe src="dept-menu/index.html" width="100%" height="650px" scrolling="no" frameborder="0"></iframe>
                    <iframe id="newsFrame" src="dept-news/news.html" width="100%" height="300px" scrolling="no" frameborder="0"></iframe>
</asp:Content>
HTML
 <input type="submit" name="ctl00$ContentPlaceHolder2$Button1" value="" id="Button1" />
       <script type="text/javascript">
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('ctl00$ContentPlaceHolder2$SM1', 'form1', ['tctl00$ContentPlaceHolder2$UpdatePanel1','ContentPlaceHolder2_UpdatePanel1'], [], [], 90, 'ctl00');
//]]>
</script>
<div id="ContentPlaceHolder2_UpdatePanel1">
        <input type="hidden" name="ctl00$ContentPlaceHolder2$HiddenField1" id="HiddenField1" />
                This is HOME 
        <br /><br />
</div>
At runtime the error says that they can't set the value of a null reference. What am I doing wrong? Thanks in advance.
P.S. the iframe is called from the contentplaceholder.
 
    