重定向到新的ASP.NET页面 [英] Redirecting to new page ASP.NET
问题描述
我有麻烦尝试按钮被点击后重定向到一个新的一页。但是,此按钮也节省了我的DataTable到Excel文件。我希望它能够保存和重定向在同一时间。
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.
这是该按钮
protected void SaveButton_Click(object sender, EventArgs e)
{
this.SaveExcel();
Response.Redirect("Default.aspx", true);
}
另外,在.aspx页面中我有这个
Also in the .aspx page i have this
<asp:Button ID="SaveButton" runat="server" Text="Save"
onclick="SaveButton_Click" Enabled="False" onclientclick="needToConfirm=false"/>
你可以看到我有哪些需要一个onlclientclick功能。
as you can see i have a onlclientclick function which is needed.
我已经使用JavaScript,也是Server.Transfer的metothds尝试。有没有人有一个想法如何做到这一点?
I have tried using javascript and also the Server.Transfer metothds. Has anyone got an idea how to do this?
推荐答案
您的OnClientClick
应在以下格式。
OnClientClick="needToConfirm(); return false"
如果这不起作用没有在你的JavaScript错误将导致你的C#code不火。
If this doesn't work there is an error in your JavaScript which is causing your c# code not to fire.
这篇关于重定向到新的ASP.NET页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!