Asp.net codebehind from javascript?
<p>Is it possible to call asp.net codebehind function from javascript in vs2008?<br>
My problem is, I have two codebehind methods, one is for some validation and it will return true or false.
This method will be called when user click submit button and if return value is true,
I want to call javascript function for confirm(confirm dialog box) and if it is OK,<br>I will call 
another codebehind method for update. If validation method return false or javascript cancel,
nothing changes.
Now, my code is like this:</p>

<pre><code>&lt;script language="javascript" type="text/javascript"&gt;
function Confirm()
{
    var checkUpdate = confirm("Do you wish to save changes?");
    if (checkUpdate)
    {
        return true;
    }
    else 
    {
        return false;
    }
}

protected void Button1_Click(object sender, EventArgs e)
{
    if(CheckValidate())
    {
        string script = "&lt;SCRIPT LANGUAGE='JavaScript'&gt; ";
                    script += "Confirm()";
                    script += "&lt;/SCRIPT&gt;";
                    Page.RegisterStartupScript("ClientScript", script);

        //If Javascript Ok Call Update,Otherewise,nothing;  
    }
}

private boolean CheckValidate()
{
    return boolean;
}

private void UpdateData()
{
    //Update;   

 }
</code></pre>

<p>However, it goes immediately to update method and after updating, javascript confirmation box 
comes out.</p>

<p>How i change to get right sequence? please give me the right way.</p>
