Button OnClick not firing on first click in ASP.NET?

后端 未结 5 1778
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-07 02:14
protected void ButtonCancel_Click(object sender, EventArgs e)
    {

        Response.Redirect(\"~/Logon.aspx\");
    }

this is not workin

5条回答
  •  -上瘾入骨i
    2021-01-07 02:36

    Do you have form tag in master page or this page?

    <%@ Page Title="About" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="About.aspx.cs" Inherits="WebApplication2.About" %>
    
    
        

    <%: Title %>.

    Your application description page.

    Use this area to provide additional information.

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebApplication2 { public partial class About : Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_ServerClick(object sender, EventArgs e) { Response.Write("hello"); } protected void Button2_Click(object sender, EventArgs e) { Response.Write("hello"); } } }

    Master page

    <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="WebApplication2.SiteMaster" %>
    
    
    
    
    
        
        
        <%: Page.Title %> - My ASP.NET Application
    
        
            <%: Scripts.Render("~/bundles/modernizr") %>
        
        
        
    
    
    
        
    <%--To learn more about bundling scripts in ScriptManager see https://go.microsoft.com/fwlink/?LinkID=301884 --%> <%--Framework Scripts--%> <%--Site Scripts--%>

    © <%: DateTime.Now.Year %> - My ASP.NET Application

提交回复
热议问题