Marco Dinatsoli
Marco Dinatsoli

Reputation: 10570

asp.net execute javascript function after finishing the button click

I have this asp.net button

<asp:Button ID="okButton" runat="server" Text="Okay" OnClick="okButton_Click"  />

this is the onButton_Click function

protected void okButton_Click(object sender, EventArgs e){
//bla bla bla
//bla bla bla
}

I have also this javascript function

function callCenterDailyChartYMC() {
//bla bla bla
}

My question

How can I execute that javascript function after finishing executing the button on click function?

Thanks

Upvotes: 1

Views: 1255

Answers (1)

ElGavilan
ElGavilan

Reputation: 6894

You can register it as a startup script.

protected void okButton_Click(object sender, EventArgs e){
    ClientScriptManager cs = Page.ClientScript;
    string script = "callCenterDailyChartYMC();";
    cs.RegisterStartupScript(this.GetType(),"NameOfYourScript",script,true);
}

http://msdn.microsoft.com/en-us/library/z9h4dk8y(v=vs.110).aspx

Upvotes: 1

Related Questions