简体   繁体   English

将事件处理程序从aspx页面上的源视图添加到按钮

[英]Add event handler to button from source view on an aspx page

I have a pretty complex html design of an aspx page on my proyect and neither the Design or the Split view show the complete list of controllers, because of that problem i need to add an event handler to a button just from the source view. 我在proyect上有一个非常复杂的HTML设计,该页面上没有一个aspx页面,“设计”或“拆分”视图都没有显示完整的控制器列表,因为这个问题,我只需要从源视图向按钮添加事件处理程序即可。

How i can add a event handler to a button just from the source view on c#? 我如何仅从C#的源视图向按钮添加事件处理程序?

If I understand your question correct, you can attach click event using += . 如果我对您的问题的理解正确,则可以使用+=附加点击事件。

protected void Page_Init(object sender, EventArgs e)
{
    SubmitButton.Click += SubmitButton_Click;
}

private void SubmitButton_Click(object sender, EventArgs e)
{
    // Do something
}

If you are using VB.Net, you can use the OnClick attribute or some other attribute basing on the required event you want to handle. 如果使用的是VB.Net,则可以基于要处理的必需事件使用OnClick属性或其他一些属性。 Otherwise, you can always do it using the code-behind file and attach the event as suggested by Win. 否则,您始终可以使用代码隐藏文件来执行此操作,并根据Win的建议附加事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM