第一次使用asp/web表单时,我认为下面的代码会改变我的web表单按钮。但当我运行'site‘并点击按钮时,它似乎只是刷新页面,而不是改变按钮的文本。我像往常一样从工具箱中拖出按钮。
protected void Button1_Click(object sender, EventArgs e)
{
Button1.Text = "result";
}在使用web表单时,我还需要做什么吗?
更新UI源代码
<p>
ASP.NET555 Web Forms lets you build dynamic websites using a familiar drag-and-drop, event-driven model.
A design surface and hundreds of controls and components let you rapidly build sophisticated, powerful UI-driven sites with data access.
<asp:Table ID="Table1" runat="server">
</asp:Table>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" Width="244px" />
<asp:Label ID="Label1" runat="server" Text="555"></asp:Label>
555test</p>该按钮似乎正确地指向Button1_Click事件。
发布于 2016-03-01 17:50:59
一个原因可能是事件可能不是为按钮创建的,你可以通过删除事件处理程序来检查它,添加更多事件处理程序,这可能会解决按钮事件的问题
<asp:Button ID="Button1" OnClick="Button1_Click" runat="server" />检查UI元素上的单击事件是否正确
复制方法的情况也会受到影响
如果添加了按钮的CausesValidation = "True"属性,这也是事件可能不会触发的一个原因
更新按钮的UI代码
https://stackoverflow.com/questions/35719377
复制相似问题