简体   繁体   English

ASP.NET按钮未触发事件

[英]Asp.net button is not firing event

I am having an issue with the asp.net button. 我的asp.net按钮有问题。 It is not firing event. 这不是触发事件。 I tried setting causes validation to false and removing the java script and validation but it still doesn't work. 我尝试将导致验证的设置设置为false并删除了Java脚本和验证,但仍然无法正常工作。

<asp:Button ID="Button2" runat="server" Text="Save" onclick="Button2_Click" />


protected void Button2_Click(object sender, EventArgs e)
{
    std.AddGuardianInfo(
        Convert.ToInt16(DropDownList1.SelectedValue), 
        TextBox6.Text, 
        TextBox7.Text, 
        TextBox8.Text, 
        TextBox9.Text, 
        TextBox10.Text);
    Response.Redirect("Std_FeeInfo.aspx");
}

Change onclick to OnClick in the markup of the asp:button . asp:button的标记中将onclick更改为OnClick so the markup will be like this: 因此标记将如下所示:

<asp:Button ID="Button2" runat="server" Text="Save" OnClick="Button2_Click" />

And an important advise for you: Use css for styling and arranging elements in your page, giving space using a sequence of &nbsp; 并为您提供了一个重要的建议: 使用css设置页面中元素的样式和排列方式,并使用一系列&nbsp; will not be a good design 不会是一个好的设计

You want to check this steps. 您要检查此步骤。

  • @rabiya are you copied this code in some where else ? @rabiya您是否在其他地方复制了此代码? Then just remove it and double click on your asp button. 然后只需将其删除,然后双击您的asp按钮即可。
  • If you are using updatepanel on onclick event, this may happen.So Use ' EnableEventValidation="false" ' 如果在onclick事件上使用updatepanel,则可能会发生这种情况。因此,请使用' EnableEventValidation="false" '

Example : 范例:

<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="false"  CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

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

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