在code取出asp.net事件背后 [英] Remove asp.net event on code behind

查看:145
本文介绍了在code取出asp.net事件背后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想删除在code后面的事件。

I want to remove an event in code behind.

例如我的控制是这样的。

For example my control is like this.

<asp:Textbox ID="txtName" runat="server" OnTextChanged="txtName_Changed" AutoPostBack="true" />

我要删除 OnTextChanged 编程..我怎样才能做到这一点?

I want to remove the OnTextChanged programmatically.. how can I achieve this?

推荐答案

在C#中,你可以添加和很容易移除事件处理程序的code-背后:

In C#, you can add and remove event handlers quite easily from the code-behind:

// Add event handler:
txtName.OnTextChanged += new EventHandler(txtName_Changed);

// Remove event handler:
txtName.OnTextChanged -= new EventHandler(txtName_Changed);

这篇关于在code取出asp.net事件背后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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