0

这很奇怪!下面的代码在 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>

这是代码文件:

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()。先感谢您。

4

1 回答 1

0

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

于 2012-05-24T11:15:58.300 回答