在同一页面上使用多个用户控件时,如何在单击按钮时停止多次回发? [英] how to stope multiple postbacks on button click while using multiple user controls on same page ?

查看:68
本文介绍了在同一页面上使用多个用户控件时,如何在单击按钮时停止多次回发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,
我在同一页面上使用了5个不同的用户控件,即我已经创建了
具有.ascx文件的5页,每页上都有一些文本框
他们的名字是
1. signup1.ascx
2. signup2.ascx
3. signup3.ascx
4. signup4.ascx
5. signup5.ascx
每个.ascx文件的文本框都会对textChanged执行一些任务.
和m在页面名称上将这些控件用作
signup.aspx是我的应用程序的启动页面,因此,当m在signup1.ascx文件的文本框中键入一些文本时,所有页面都回发,我希望如果m在signup1.ascx文件的文本框中键入,则仅应张贴该页面返回,其他保持不变.

Hello friends,
I m using 5 different user controls on same page, i.e I have created
5 pages with .ascx files,having some text boxes on each page
their names are as
1. signup1.ascx
2. signup2.ascx
3. signup3.ascx
4. signup4.ascx
5. signup5.ascx
textbox of each .ascx file persorm some task on textChanged.
and m using these controls on page names as
signup.aspx which is my startup page of applycation, so when m typing some text on textbox of signup1.ascx file all the pages post back, I want that if m typing in textbox of signup1.ascx file then only this page should be post back, and other remains same

推荐答案

我不确定您到底想要什么.如果您发布一些代码,将会很有帮助.

我猜想您的5个控件都使用相同的回调函数.要做的一件事是为每个控件使用不同的回调函数.

还有其他可能更好的方法来解决此问题,但是它们更多地取决于您的实现方式,因此,如果没有从头开始的代码示例,我不确定哪一种是最好的向您展示.
I''m not sure exactly what you want. If you post some code, it would be helpful.

I''m guessing that your 5 controls all use the same callback function. One thing to do would be to use a different callback function for each control.

There are other, possibly better ways to fix this as well, but they depend more on how you are implementing, so without a code example to start from, I''m not sure which one is best to show you.


将Ajax更新面板放在aspx页面中,并将ascx文件放入其中.
place Ajax update panel in your aspx page and put your ascx file inside it.


您无法避免.这是Page生命周期的一部分.

您可以做的最大事情是在回发之前设置一个标志,并根据该标志避​​免执行PageLoad中存在的代码.
因此,执行肯定会在所有用户控件页面加载过程中继续进行.
You cannot avoid it. It''s part of Page life cycle.

What maximum you can do is set a flag before postback and based on the flag avoid executing code present in the PageLoad.
As such, execution would definitely pass on through all the user controls page load.


这篇关于在同一页面上使用多个用户控件时,如何在单击按钮时停止多次回发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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