server.Transfer不工作

https://www.codeproject.com/Questions/56736/How-to-use-Server-Transfer-from-Ajax-UpdatePanel

For Server.Transfer to work with UpdatePanel.

for getting update panel to post back.
we need to register post back contorl with the scriptmanager.

ScriptManager1.RegisterPostBackControl(button1);

and in this control you can do server.transfer.


btnAction这个按钮点击之后,后台有异常,触发了OnError事件。
OnError事件中有Server.Transfer的代码。

需要使用script manager注册一下btnAction

   var scriptManager = ScriptManager.GetCurrent(Page);
                scriptManager?.RegisterPostBackControl(btnAction);

调试技巧:

直接在源码中切换到target 页面,在page_load中加断点。看是否已经进入了target页面。

原文地址:https://www.cnblogs.com/chucklu/p/10758124.html