按钮在Click事件不触发 [英] Button On Click event not firing

查看:111
本文介绍了按钮在Click事件不触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在上单击事件在其他页面虽然工作

这里的页面我想要得到它的工作头:

 <%@页标题=报告LANGUAGE =C#的MasterPageFile =〜/ Site.master母AutoEventWireup =真
    codeFILE =Report.aspx.cs继承=报告%GT;    <%@ previousPageType VirtualPath =〜/ Default.aspx的>

和背后的code:

 保护无效的Page_Load(对象发件人,EventArgs的发送)
    {
        如果(previousPage == NULL)
        {
            的Response.Redirect(〜/ Default.aspx的);
        }
            // code ..

当我点击它,它只是重定向我到previousPage。它也当它内部有一个断点不会甚至停止。

 保护无效export_Click(对象发件人,EventArgs的发送)
    {
           // code
    }


解决方案

在你的页面加载,请尝试使用:

 如果(!Page.IsPostBack)
{
      如果(previousPage == NULL)
      {
          的Response.Redirect(〜/ Default.aspx的);
      }}

the on click event works in other pages though.

here's the header of the page i'm trying to get it to work:

<%@ Page Title="Report" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Report.aspx.cs" Inherits="Report" %>

    <%@ PreviousPageType VirtualPath="~/Default.aspx">

and the code behind:

protected void Page_Load(object sender, EventArgs e)
    {
        if (PreviousPage == null)
        {
            Response.Redirect("~/Default.aspx");
        }
            // code..

when i click on it, it just redirects me to the PreviousPage. it also doesn't stop even when it has a breakpoint inside.

protected void export_Click(object sender, EventArgs e)
    {
           //code
    }

解决方案

In your Page Load, try using:

if(!Page.IsPostBack)
{
      if (PreviousPage == null)
      {
          Response.Redirect("~/Default.aspx");
      }

}

这篇关于按钮在Click事件不触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆