asp.net 自定义服务器控件 - 如何判断是否由于该控件而发生回发
我有一个自定义的 asp.net 服务器控件(实际上是复选框的专用版本)。 我想对回发进行一些处理,但前提是回发是单击此控件的结果(自动回发设置为 true)。 确定回发是此控制的结果还是其他原因的最佳方法是什么?
感谢您的帮助。
I have a custom asp.net server control (actually a specialized version of a checkbox). I want to do some processing on a postback but only if the postback was a result of this control being clicked (with autopostback being set to true). What is the best way to determine if the postback is a result of this control or something else?
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您也许可以让它工作:
构建逻辑,告诉您发回哪个控件:
http: //www.eggheadcafe.com/articles/20050609.asp
Cory Larson 评论也很好......:)
You might be able to get this to work:
Build logic that tells you which control posted back:
http://www.eggheadcafe.com/articles/20050609.asp
Cory Larson comment is also a good one... :)
听起来您可以使用 事件冒泡 。 基本上,您只需从自定义服务器控件中公开复选框中的 onchange 事件(如果您的服务器控件是复合控件)。 然后在托管控件的页面的事件处理程序中编写特殊处理代码。
It sounds like you could use event bubbling. Basically you would just expose the onchange event in your checkbox (if your server control is a composite control) from you custom server control. Then write your special handling code in an eventhandler in the page hosting the control.