簡體   English   中英

ASP.NET按鈕未觸發事件

[英]Asp.net button is not firing event

我的asp.net按鈕有問題。 這不是觸發事件。 我嘗試將導致驗證的設置設置為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");
}

asp:button的標記中將onclick更改為OnClick 因此標記將如下所示:

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

並為您提供了一個重要的建議: 使用css設置頁面中元素的樣式和排列方式,並使用一系列&nbsp; 不會是一個好的設計

您要檢查此步驟。

  • @rabiya您是否在其他地方復制了此代碼? 然后只需將其刪除,然后雙擊您的asp按鈕即可。
  • 如果在onclick事件上使用updatepanel,則可能會發生這種情況。因此,請使用' EnableEventValidation="false" '

范例:

<%@ 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