我已经使用 HTML 在 Visual Studio 2015 中的 Web 表单中添加了按钮。所以这些按钮在设计选项卡中。当我双击“设计”选项卡中的按钮时。它没有打开 ASPX.CS 页面。那是正常的吗?我的印象是我会那样工作。相反,我必须去手动编写每个事件处理程序的代码。
我搜索了谷歌并尝试在 Visual Studio 上进行修复,但没有发现任何效果。
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="Module2LabExercise.WebForm1" %>
<!DOCTYPE html>
<html>
<head>
<title>
Currency Converter
</title>
</head>
<body>
<form runat = "server">
<div>
Convert:
<input type = "text" ID = "US" runat = "server" />
U.S. dollars to
<select ID = "Currency" runat = "server" />
<br /> <br />
<input type = "submit" value = "OK" ID = "Convert"
OnServerClick = "Convert_ServerClick" runat = "server" />
<input type = "submit" value = "Show Graph" ID = "ShowGraph"
OnServerClick = "ShowGraph_ServerClick" runat = "server" />
<br /> <br />
<img id="Graph" runat="server" src="//:0"/>
<br /> <br />
<p style = "font-weight: bold" ID = "Result" runat = "server"
>
</p>
</div>
</form>
</body>
</html>
`
我在想,如果我双击按钮。它会自动打开事件处理程序并创建事件处理程序。如果我错了。请纠正我并让我知道。来这里是因为我没有想法。
最佳答案
您在按钮实现的后端添加该代码: 这是代码
Response.redirect("ex.aspx");
ex.aspx是你的文件名
如果它不工作然后添加:
Server.Transfer("ex.aspx");
关于c# - 为什么我在 Visual Studio 中的 HTML 按钮在双击时没有创建事件处理程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56213912/