双重回发问题

发布于 2024-07-05 06:01:04 字数 450 浏览 7 评论 0原文

我有一个 ASP.NET 1.1 应用程序,我试图找出为什么当我更改 ComboBox 的值用于填充另一个值(父子关系)时,会产生两个回发。

我查了又查代码,也没找到原因。

这是两个以 page_load 结尾的调用堆栈

第一次回发(由 ComboBox 的自动回发生成)

回发调用堆栈(损坏)

第二次回发(这就是我想找出它发生的原因)

替代文本(已损坏)

有什么建议吗? 我可以检查什么?

I have a ASP.NET 1.1 application, and I'm trying to find out why when I change a ComboBox which value is used to fill another one (parent-child relation), two postbacks are produced.

I have checked and checked the code, and I can't find the cause.

Here are both call stacks which end in a page_load

First postback (generated by teh ComboBox's autopostback)

Postback call stack (broken)

Second postback (this is what I want to find why it's happening)

alt text (broken)

Any suggestion? What can I check?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

何止钟意 2024-07-12 06:01:05

这是很旧的帖子,但人们仍在寻找与我上周完全相同的解决方案。

正如格伦比所说,双重事件是主要原因 - 但删除其中一个并不总是一种选择。 至少就我的情况而言,我必须在第 3 方的应用程序中解决此问题。

我在母版页上添加了以下脚本并修改了 ASP 表单:

<script>var Q = 0;</script>
<form id="Form1" runat="server" onsubmit="Q++; if(Q==1){return true;} else { return false;}">

这似乎有效,请转发您的评论。

阿伦

http://www.velocityreviews.com/forums /t117900-asp-net-multiple-postback-issue.html

This is very old post, but people still looking at this for solution exactly same as I did last week.

Like Grengby said Double events are primary reasons - but removing one of them is not allways an option. Atleast on my case and I had to resolve this on 3rd party's application.

I added following script and amended ASP form on masterpage:

<script>var Q = 0;</script>
<form id="Form1" runat="server" onsubmit="Q++; if(Q==1){return true;} else { return false;}">

This seems to be working and please forward your comments.

Arun

http://www.velocityreviews.com/forums/t117900-asp-net-multiple-postback-issue.html

水溶 2024-07-12 06:01:04

这是这段代码的一个非常具体的问题,我怀疑它对其他人是否有用,但事情是这样的:

用 if 向组合的 onchange 添加了一个检查,如果满足条件,则显式调用了回发函数。
如果组合设置为 AutoPostback,asp.net 会再次添加回发调用,产生两个回发...

生成的 html 如下所示:

[select onchange="javascript: if (CustomFunction()){__doPostBack('name','')}; __doPostBack('name','')"]

It's a very specific problem with this code, I doubt it will be useful for someone else, but here it goes:

A check was added to the combo's onchange with an if, if the condition was met, an explicit call to the postback function was made.
If the combo was set to AutoPostback, asp.net added the postback call again, producing the two postbacks...

The generated html was like this:

[select onchange="javascript: if (CustomFunction()){__doPostBack('name','')}; __doPostBack('name','')"]
半葬歌 2024-07-12 06:01:04

我要查找的第一件事是您没有将第二个 ComboBox 的 AutoPostBack 属性设置为 true。 如果您更改第二个组合中的值并将该属性设置为 true,我相信它将在该控件上生成回发。

First thing I would look for is that you don't have the second ComboBox's AutoPostBack property set to true. If you change the value in the second combo with that property set true, I believe it will generate a postback on that control.

八巷 2024-07-12 06:01:04

您有可以分享的代码吗? 当年在经典 ASP 中,双回发给我带来了很大的困扰,最终促使我一劳永逸地转向 .NET。 每当我在 .NET 中遇到此类问题时,我都会转到每个 CONTROL 和每个 PAGE 元素(例如加载、初始化、预渲染、单击、SelectedIndexChanged 等)并放置断点。

即使我在那里没有代码,我也会插入类似的内容:

Dim i As Integer
i = 0

我通常能够查明一些我没有预料到的操作,并根据需要进行修复。 我建议你在这里这样做。

祝你好运。

Do you have any code you could share? Double post backs plagued me so much in classic ASP back in the day that it was what finally prompted me to switch to .NET once and for all. Whenever I have problems like these for .NET, I go to every CONTROL and every PAGE element like load, init, prerender, click, SelectedIndexChanged, and the like and put a breakpoint.

Even if I don't have code there, I'll insert something like:

Dim i As Integer
i = 0

I am usually able to pinpoint some action that I wasn't expecting and fix as needed. I would suggest you do that here.

Good luck.

戏蝶舞 2024-07-12 06:01:04

检查 Request.Form["__EVENTTARGET"] 以查找启动回发的控件 - 这可能会帮助您缩小范围。

查看调用堆栈和一些反射(进入 ASP.NET 2 - 我手头没有 1.1) - 看起来 SessionStateModule.PollLockedSessionCallback 是 HttpApplication 启动例程的一部分。 您的应用程序可能正在被回收 - 我很确定事件会为此被写入事件日志中。

我唯一的其他建议是使用 Fiddler 或客户端上的其他工具来捕获 HTTP 流量。

Check Request.Form["__EVENTTARGET"] to find the control initiating the postback - that may help you narrow it down.

Looking at the callstacks, and some Reflectoring (into ASP.NET 2 - I don't have 1.1 handy) - it looks like SessionStateModule.PollLockedSessionCallback is part of the HttpApplication startup routines. It may be possible that your app is being recycled - I'm pretty sure an event gets written into the Event log for that.

My only other suggestion would be Fiddler or something on the client to capture HTTP traffic.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文