按钮单击IIS上的事件未执行

时间:2012-05-24 11:09:27

标签: c# asp.net

这很奇怪!当在VS2010中使用F5时,下面的代码正确运行,但是当我在IIS7服务器上运行时,按钮点击事件不会触发!我不能为我的生活搞清楚这一点!这是代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="default.aspx.cs" Inherits="_default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <script type="text/javascript">
        //Put your JavaScript code here.
    </script>
    <div>
        Hi World!<br />
        <br />
        <br />
        <asp:Button ID="button1" Text="Click Here" runat="server" OnClick="button1_Click" />
        <br />
        <br />
        <asp:Button ID="Button3" runat="server" onclick="Button3_Click" Text="Button" />
        <br />
        <br />
        <asp:TextBox ID="results" runat="server" TextMode="MultiLine" Height="350px" Width="500px"></asp:TextBox>
    </div>
    </form>
</body>
</html>

这是CodeFile:

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;

public partial class _default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.results.Text += "In Page_Load ";
    }

    protected void button1_Click(object sender, EventArgs e)
    {


        this.results.Text += "Hello! ";

        return;
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        this.button1_Click(sender, e);
        return;
    }
}

Page_Load()确实运行,但不是button1_Click()。提前谢谢。

1 个答案:

答案 0 :(得分:0)

您可能还需要从runAllManagedModulesForAllRequests中移除web.config设置(如果有)(或将其设置为false)。