Reputation: 365
I am having trouble trying to redirect to a new page after the button has been clicked. But this button also saves my datatable into an excel file. I want it to be able to save and redirect at the same time.
this is the code in the .CS file for the button
protected void SaveButton_Click(object sender, EventArgs e)
{
this.SaveExcel();
Response.Redirect("Default.aspx", true);
}
Also in the .aspx page i have this
<asp:Button ID="SaveButton" runat="server" Text="Save"
onclick="SaveButton_Click" Enabled="False" onclientclick="needToConfirm=false"/>
as you can see i have a onlclientclick function which is needed.
I have tried using javascript and also the Server.Transfer metothds. Has anyone got an idea how to do this?
Upvotes: 0
Views: 1000
Reputation: 2855
Your OnClientClick
should be in the following format.
OnClientClick="needToConfirm(); return false"
If this doesn't work there is an error in your JavaScript which is causing your c# code not to fire.
Upvotes: 3