[英]Redirecting to new page ASP.NET
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. 但是此按钮还将我的数据表保存到excel文件中。 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 这是.CS文件中按钮的代码
protected void SaveButton_Click(object sender, EventArgs e)
{
this.SaveExcel();
Response.Redirect("Default.aspx", true);
}
Also in the .aspx page i have this 在.aspx页面上我也有这个
<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. 如您所见,我有一个需要的onlclientclick函数。
I have tried using javascript and also the Server.Transfer metothds. 我尝试使用javascript以及Server.Transfer方法。 Has anyone got an idea how to do this? 有谁知道如何做到这一点?
Your OnClientClick
should be in the following format. 您的OnClientClick
应该采用以下格式。
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. 如果这不起作用,则说明您的JavaScript中出现错误,导致c#代码无法触发。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.