How to submit an ASPX form using C# on the Pageload event
<p>I have form tag in an ASPX page,</p>

<pre><code>&lt;form id="payForm" method="post" action="&lt;%Response.Write(URL);%&gt;" runat="server"&gt;
&lt;/form&gt;
</code></pre>

<p>On the pageload event,</p>

<pre><code>Literal mylit = new Literal();
mylit.Text = string.Format("&lt;input type=\"hidden\" name=\"{0}\" value=\"{1}\" /&gt; \n", name, value); 
payForm.Controls.Add(mylit);
</code></pre>

<p><strong>How do I make my form to submit after adding this control defined in pageload event?</strong></p>

<p>If I write this code</p>

<pre><code> &lt;script language="javascript" type="text/javascript"&gt;
        document.forms["payForm"].submit();
 &lt;/script&gt;
</code></pre>

<p>then this snipet of code also cannot find the <code>payForm</code> object.</p>
