Dynamically generated HTML code and window.open function
<p>This is 2003 VB code (asp.net) that I converted to VS 2010. It used to work fine in VS2003. Currently running on dotnet framework 4.0 with IIS 7.5</p>

<p>There is a function <code>setdate</code> that ia defined in the    <code>&lt;head&gt;</code>     section of an aspx page</p>

<pre><code>&lt;script language="javaScript" type="text/javascript"&gt;
    function setDate(date) {       
      window.opener.document.getElementById("txtDueDate").value = date;
      window.close();
    }
&lt;/script&gt;
</code></pre>

<p>The call to this function is dynamically generated HTML code that is inserted into the DOM. 
When I view the source code I see that this code has been inserted before the ending form tag</p>

<pre><code>    &lt;script language="javascript" type="text/javascript"&gt;setDate('5/22/2013');&lt;/script&gt;
  &lt;/form&gt;
  &lt;script language="javascript" type="text/javascript"&gt;
     var yTop = (screen.availHeight - document.body.clientHeight) / 2;
     var xLeft = (screen.availWidth - document.body.clientWidth) / 2;
     window.moveTo(xLeft, yTop);
  &lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>When I put an alert box in the <code>setDate</code> function it shows up with the correct value for <code>date</code>, but the function is not populating the parent window.</p>

<p>Not sure why. Please help</p>
