有没有什么解决方法在UpdatePanel + Server.Transfer的问题?

编程入门 行业动态 更新时间:2024-10-14 22:17:48
本文介绍了有没有什么解决方法在UpdatePanel + Server.Transfer的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图用一个UpdatePanel在我的ASP.NET应用程序。不幸的是,似乎我不能做到这一点如果我在我的应用使用Server.Transfer的()。

I'm trying to use an UpdatePanel in my ASP.NET application. Unfortunately, it seems that I can't do this if I am using Server.Transfer() in my application.

修改应用程序的分量是不可能的 - 该架构广泛使用的Server.Transfer的() - 在本质上,每一个页面请求通过这个方法。有没有什么解决办法存在这个问题存在吗?不必做整版回发是如此的不合时宜的这些天...

Modifying that component of the application is not possible - the architecture makes extensive use of Server.Transfer() - in essence, every page request goes through this method. Does any workaround exist for this issue exist? Having to do full-page postbacks is so unfashionable these days...

推荐答案

我知道了!感谢噩的陌生的外语博客的:)

I've got it! Thank Og for strange foreign language blogs :)

要解决这个问题,我可以简单地告诉ASP.NET AJAX客户端框架直接在Server.Transfer的()调用的真正目标引导部分请求。我很害怕可能的副作用(谁知道这是什么跳过 - 基础设施确实有一个目的),但它似乎是工作的罚款,到目前为止

To fix it, I can simply tell the ASP.NET AJAX client-side framework to direct the partial request directly at the real target of the Server.Transfer() call. I am quite scared of the possible side-effects (who knows what this skips - the infrastructure does have a purpose) but it seems to be working fine so far.

下面是解决了这个问题,叫我的网页的加载事件的方法:

Here is the method that fixes the problem, called in my page's Load event:

/// /// Adds to the page a JavaScript that corrects the misbehavior of AJAX when a page is target of a Server.Transfer call. /// protected void AjaxUrlBugCorrection() { string actualFile = Server.MapPath(AppRelativeVirtualPath); string redirectFile = Server.MapPath(Context.Request.FilePath); string baseSiteVirtualPath = HttpRuntime.AppDomainAppVirtualPath; if (actualFile != redirectFile) { System.Text.StringBuilder sbJS = new System.Text.StringBuilder(); string actionUrl = string.Format("'{0}'", baseSiteVirtualPath + AppRelativeVirtualPath.Replace("~", String.Empty)); sbJS.Append("Sys.Application.add_load(function(){"); sbJS.Append(" var form = Sys.WebForms.PageRequestManager.getInstance()._form;"); sbJS.Append(" form._initialAction = " + actionUrl + ";"); sbJS.Append(" form.action = " + actionUrl + ";"); sbJS.Append("});"); ClientScript.RegisterStartupScript(this.GetType(), "CorrecaoAjax", sbJS.ToString(), true); } }

更多推荐

有没有什么解决方法在UpdatePanel + Server.Transfer的问题?

本文发布于:2023-11-22 01:03:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1615364.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:解决方法   有没有什么   UpdatePanel   Server   Transfer

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!