附加事件来控制 [英] Attaching event to a control

查看:82
本文介绍了附加事件来控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何插入一个事件aspx.cs页面。我有一个ASP:按钮,我希望在aspx.cs页面中添加该按钮的事件。它是如何做的。

How to insert an event to the aspx.cs page. I have one asp:button and i wish to add an event of that button in the aspx.cs page. how it done

推荐答案

假设你有一个这样的按钮:

Assume that you have a button like that :

<asp:Button runat="server" ID="myButton" />

您可以在您$ C $添加Click事件C-那样从后面:

You can add Click event at your code-behind like that :

myButton.Click += new EventHandler(myButton_Click);

或者你可以在这样的设计中指定您的活动:

Or you can specify your event at design like that :

<asp:Button runat="server" ID="myButton" OnClick="myButton_Click" />

这篇关于附加事件来控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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