如何手动引发回发事件... [英] How To Raise Postback Event manually...

查看:94
本文介绍了如何手动引发回发事件...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VS 2008.

在我的网络表单中,我遇到一个问题,我想手动引发回发事件
没有按钮单击,或者您可以说我希望按钮单击时需要两个
回发...

请在这方面帮助我.

预先感谢...

Hi i m using VS 2008 .

In My webform i have a problem i want To Raise Postback Event manually
without button click or you can say i want that when button clicks it takes two
Postback ...

Please help me in this regard.

Thanks in advance...

推荐答案

对不起,但这没什么意义.回发不在服务器端启动.控件包含一些在客户端执行的Java脚本.例如,当单击一个按钮时,带有各种参数的新请求将发送到服务器.

在两次回发之间,服务器上不存在您的页面实例.在每个请求(包括回发)时,将实例化该页面的新实例,贯穿其生命周期,并在将对请求的响应发送回后将其销毁.

这就是为什么从服务器端提高回发没有意义的原因.在执行此代码的那一刻,您已经处在为请求提供服务的过程中.更糟糕的是,即使您可以开始另一个回发,也肯定会再次击中相同的代码,从而导致无休止的回发序列.

我有一个想法,您正在尝试完成此操作,但这种方式行不通.如果我是对的,那么您在页面生命周期方面会遇到一些问题(每个人最初都是这样做的),并且您有这种回发想法可以在页面发生更新时进行更新,对吗?
Sorry, but that makes very little sense. Postbacks are not initiated on the server side. The controls contain some Java Script which is executed on the client side. When, for example, a button is clicked, a new request with all kinds of parameters is sent to the server.

Between postbacks no instance of your page exists on the server. At each request (including postbacks) a new instance of the page is instantiated, runs through its life cycle and is destroyed once the response to the request has been sent back.

That''s why raising postbacks from the server side makes no sense. At the moment this code is executed you are already in the middle of servicing a request. Even worse, even if you could just start another postback, it would surely hit the same code again, resulting in an endless sequence of postbacks.

I have an idea what you are trying to accomplish with this, but it does not work that way. If I''m right, you have some problem with the page life cycle (everybody does at first) and you had this postback idea to update the page whenever that happens, right?


希望 [
Hope this[^] might help you.


这篇关于如何手动引发回发事件...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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