c# - .cs 页面上的 html 按钮

标签 c# asp.net html event-handling

我在 .aspx 页面中使用 html 按钮。但我想在 .cs 页面上使用 button_click 事件。

我正在添加 html 按钮:

<button id="button1" runat="server" onclick="Submit_Click">  
    Send  
    </button>

在我使用的 .cs 页面上:

 protected void Submit_Click(object source, EventArgs e)
        {
            MessageBox.Show("ggg");
        }

我不想使用 asp 按钮 .. 这不是从 .cs 页面调用事件..

如何做到这一点..

最佳答案

您必须使用 onserverclick 而不是 onclick 方法,因为这是 HTML 按钮控件的客户端事件。

<button id="button1" runat="server" onserverclick="Submit_Click">  
Send  
</button>

关于c# - .cs 页面上的 html 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6215540/

相关文章:

c# - 从 C# 中的对象中清除所有字符串成员

.Net 反射来获取类/属性等的描述?

javascript - 自定义滚动条,在拇指周围具有灵活、扩展的轨迹,就像引力透镜一样

c# - 将 .arw 索尼照片转换为 .raw 文件

c# - System.PlatformNotSupportedException : Speech Recognition is not available on this system. 找不到 SAPI 和语音识别引擎

asp.net - 使用asp.net MVC分页搜索结果

c# - 通过表达式 EPPlus 格式化条件

javascript - 使用相机源从视频元素中提取快照

javascript - 具有 : auto centering, 适合容器内内容大小的模态容器

c# - ASP.NET MVC : How to close browser window instead of returning a view?