自定义控件加载用户控件;回发事件不会被触发 [英] Custom Control loads a user control; Postback events are not triggered

查看:350
本文介绍了自定义控件加载用户控件;回发事件不会被触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个加载用户控件自定义控件(编译为DLL)。 (即,自定义控制做了LoadControl)在用户控件是一个按钮和一个文本框。我电汇了按钮的单击事件。

I have a custom control (compiled as a DLL) which loads a user control. (i.e, the custom control does a LoadControl) In the user control is a button and a textbox. I wire up the button's click event.

我在一个值在文本框中键入。当我点击该按钮,页面做了回发。我的用户控件知道回发发生,因为Page.IsPostBack =真实的。但是,该按钮的单击事件从来没有发射,我的文本框也失去了,我在键入的值。

I type in a value into the text box. When I click the button, the page does a postback. My user control knows that a postback occured because Page.IsPostBack = true. However, the click event of the button is never fired and my text box has also lost the value that I typed in.

任何人有任何想法,以什么可能是怎么回事?

Anyone have any thoughts as to what might be going on?

编辑:
我做了这个测试并采取的SharePoint出来的图片;我是能够重现它,所以我删除了所有引用到SharePoint。

I did a test on this and took SharePoint out of the picture; I was able to reproduce it so I removed all references to SharePoint.

推荐答案

如果您是动态加载用户控件,你必须为了重新装载每个页面加载(回发或不)为.NET处理器知道在哪里要连接提交事件。

If you are dynamically loading the user control, you have to reload it on each page load (postback or not) in order for the .net processor to know where to wire up the submit event.

这篇关于自定义控件加载用户控件;回发事件不会被触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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