简体   繁体   English

ASP.net Updatepanel运行缓慢(在所有浏览器中!)

[英]ASP.net Updatepanel is slow (in all browser!)

I have a very strange problem regarding my webpage. 我的网页存在一个非常奇怪的问题。 I use an SQL query to show the user possible searchs which he/she can check out. 我使用SQL查询向用户显示他/她可以检出的可能搜索。

The problem: 问题:

The SQL query and the string formatting took about 100-200ms at top, which result a string with a HTML format. SQL查询和字符串格式在顶部花费了大约100-200ms,这导致了HTML格式的字符串。 But, on my browser (in IE, FireFox, Chrome, and tested on 5 different PC - the postback took about 2-3 SECONDS. The responded string is about 1-2kb, mostly less (sometimes it just couple hundred bytes!) 但是,在我的浏览器上(在IE,FireFox,Chrome中,并在5台不同的PC上进行了测试-回发大约需要2-3秒。响应的字符串大约是1-2kb,多数情况下会更短(有时只有几百个字节!)

There is no content in the update panel, just the generated -s, so no big dropdown list or anything at all. 在更新面板中没有内容,只有生成的-s,所以没有大的下拉列表或任何内容。

here is the snippet for the update panel: 这是更新面板的代码段:

<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <%= searchPanelPopUp %>
        </ContentTemplate>
    </asp:UpdatePanel>
</div>

And here is the c# code: http://pastebin.com/eBNTap4b 这是C#代码: http//pastebin.com/eBNTap4b

I do an async callback each time when the user change the text inside a textbox (there is a timer in the background, checking the changes each 500ms). 每当用户更改文本框内的文本时,我都会进行一次异步回调(后台有一个计时器,每500ms检查一次更改)。 If the text change, I do a callback 如果文本更改,我会进行回调

(JS code:) (JS代码:)

function raiseAsyncPostback() {
    if (searchBoxContent != document.getElementById('txtWhere').value) {
        __doPostBack("<%= this.lbtnSearchPostBackRefresh.UniqueID %>", "");
    }
    searchBoxContent = document.getElementById('txtWhere').value;
}

The page itself load about 3-5 seconds (average is 3,5s). 页面本身加载大约3-5秒(平均3.5秒)。

Do maybe have anyone any idea why this is so slow? 也许有人知道为什么这么慢吗? Or where I made a mistake? 还是我在哪里弄错了?

Thank you! 谢谢!

I think, it's not problem of update panel. 我认为,这不是更新面板的问题。 In your code behide, you are using many for inside for that is the problem. 在您的代码隐藏中,您正在内部使用许多for for这就是问题所在。 Please try other way. 请尝试其他方式。 (p/s: sorry, i'm not enouht the epunation to add comment.) (p / s:对不起,我不希望提出建议。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM