Run a javascript on postback in c#
<p>I used the below manner to run a JavaScript upon postback and it worked fine for me.</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
{
    if (this.IsPostBack)
    {
        Page.ClientScript.RegisterStartupScript(this.GetType(),"PostbackKey","&lt;script type='text/javascript'&gt;document.getElementById('apDiv1').style.visibility = 'hidden';&lt;/script&gt;");
        Page.ClientScript.RegisterStartupScript(this.GetType(),"PostbackKey","&lt;script type='text/javascript'&gt;function show()&lt;/script&gt;");
    }
    else
    {
        Page.ClientScript.RegisterStartupScript(this.GetType(),"PostbackKey","&lt;script type='text/javascript'&gt;document.getElementById('apDiv1').style.visibility = 'visible';&lt;/script&gt;");
    }
}
</code></pre>

<p>The above code worked fine and now I want to try something like below.</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
{
    if (this.IsPostBack)
    {
        Page.ClientScript.RegisterStartupScript(this.GetType(),"verify","&lt;script type='text/javascript'&gt;verify1();&lt;/script&gt;");
    }
    else
    {
    }
}
</code></pre>

<p>in the above code <code>verify1()</code> is a JavaScript linked externally to ASPX page. I am unable to execute <code>verify1()</code> function using this code. And <code>verify1()</code> function works fine when placed as <code>&lt;body onload="verify1();"&gt;</code> Is there any syntax error(s) in my above code?</p>
