UpdatePanel的慢度在IE [英] UpdatePanel Slowness in IE

查看:112
本文介绍了UpdatePanel的慢度在IE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作ASP.Net应用程序和工作,以一些Ajax添加到它加快某些地区。我正在集中第一个方面是关于孩子老师汇报出勤(和其他一些数据)出席该活动的区​​域。这需要快速。

I'm working on an ASP.Net application and working to add some Ajax to it to speed up certain areas. The first area that I am concentrating is the attendance area for the teachers to report attendance (and some other data) about the kids. This needs to be fast.

我创建了一个双控成立,其中的图标,通过JavaScript和jQuery用户点击我弹出第二控制。然后,我用__doPostBack()刷新弹出控制加载所有的相关数据。

I've created a dual-control set up where the user clicks on the icon and via Javascript and Jquery I pop up the second control. Then I use a __doPostBack() to refresh the pop up control to load all of the relevant data.

这里有一个小视频片断显示它是如何工作的:<一href=\"http://www.screencast.com/users/cyberjared/folders/Jing/media/32ef7c22-fe82-4b60-a74a-9a37ab625f1f\" rel=\"nofollow\">http://www.screencast.com/users/cyberjared/folders/Jing/media/32ef7c22-fe82-4b60-a74a-9a37ab625f1f (:21,而忽略音频背景)

Here's a little video snippet to show how it works: http://www.screencast.com/users/cyberjared/folders/Jing/media/32ef7c22-fe82-4b60-a74a-9a37ab625f1f (:21 and ignore the audio background).

这是慢于我希望在Firefox和Chrome 2-3秒为每一个弹出,但它是完全行不通的IE浏览器,以7-8轻松每一秒它会弹出并加载时间。而无视所需要保存的数据,它已经改变了之后的任何时间。

It's slower than I would like at 2-3 seconds in Firefox and Chrome for each "popping up", but it's entirely unworkable in IE, taking easily 7-8 seconds for each time it pops up and loads. And that disregards any time that is needed to save the data after it's been changed.

下面是处理弹出的JavaScript:

Here's the javascript that handles the pop-up:

function showAttendMenu(callingControl, guid) {
var myPnl = $get('" + this.MyPnl.ClientID + @"')
if(myPnl) {
	var displayIDFld = $get('" + this.AttendanceFld.ClientID + @"');
	var myStyle = myPnl.style;
	if(myStyle.display == 'block' && (guid== '' || guid == displayIDFld.value)) {
		myStyle.display = 'none';
	} else {
		// Get a reference to the PageRequestManager.
		var prm = Sys.WebForms.PageRequestManager.getInstance();

		// Unblock the form when a partial postback ends.
		prm.add_endRequest(function() {
			$('#" + this.MyPnl.ClientID + @"').unblock({ fadeOut: 0});
		});

		var domEl = Sys.UI.DomElement;
		//Move it into position
		var loc = domEl.getLocation(callingControl);
		var width = domEl.getBounds(callingControl).width;
		domEl.setLocation(myPnl, loc.x + width, loc.y - 200);

		//Show it and block it until we finish loading the data
		myStyle.display = 'block';
		$('#" + this.MyPnl.ClientID + @"').block({ message: null, overlayCSS: { backgroundColor:'#fff', opacity: '0.7'} }); 

		//Load the data
		if(guid != '') { displayIDFld.value = guid; } 
		__doPostBack('" + UpdatePanel1.ClientID + @"','');
	}
}}

首先,我不明白为什么__doPostBack()介绍了在IE这样的延迟。如果我采取和prm.add_endRequest出来,就因为没有回发发生非常迅速。

First, I don't understand why the __doPostBack() introduces such a delay in IE. If I take that and the prm.add_endRequest out, it's VERY speedy as no postback is happening.

第二,我需要一种方法来弹出该控制并刷新数据,以便它仍然是互动的。我没有结婚到一个UpdatePanel,但我一直无法弄清楚如何使用Web服务/静态页面的方法做到这一点。正如你可以看到这个控件加载多次在同一页上使页面大小和下载速度是一个问题。

Second, I need a way to pop up this control and refresh the data so that it is still interactive. I'm not married to an UpdatePanel, but I haven't been able to figure out how to do it with a Web Service/static page method. As you can see this control is loaded many times on the same page so page size and download speed is an issue.

我倒是AP preciate什么想法?

I'd appreciate any ideas?

编辑:这是在IE 6或7。我想它与IE浏览器的处理的UpdatePanel做同样的,因为同样的code是在FF和Chrome更快

It's the same in IE 6 or 7. I'm thinking it has to do with IE's handling of the UpdatePanel, because the same code is much faster in FF and Chrome.

推荐答案

如果速度/性能是你主要关心的问题,我会强烈建议反对的UpdatePanel,因为它们会导致一整页回发的拖累ViewState中的头,除其他垃圾,并强制页面每次都要经过整个生命周期(即使用户没有看到这一点)。

If speed/performance is a major concern for you, I would strongly suggest against UpdatePanels, as they cause a full page postback that drags the ViewState in the header, among other crap, and forces the page to go through the whole life cycle every time (even though the user doesn't see this).

您应该能够(相对容易)使用PageMethods来完成你的任务。

You should be able to (relatively easily) use PageMethods to accomplish your task.

// In your aspx.cs define the server-side method marked with the 
// WebMethod attribute and it must be public static.
[WebMethod]
public static string HelloWorld(string name)
{
  return "Hello World - by " + name;
}

// Call the method via javascript
PageMethods.HelloWorld("Jimmy", callbackMethod, failMethod);

这篇关于UpdatePanel的慢度在IE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆