1

ASP.NET C# で簡単な Web サイトを構築しました。

Visual Studioで[RUN]を押したら正常に動きました。

しかし、Web ホスティング サーバーにアップロードした後、ボタンをクリックしても何も起こりません。「Label1」は何も変更していません。ノーポストバックのようです。

何が起こるのですか?何が見逃されていますか?

Default.aspx は次のとおりです。

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MyWebApp._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">
    <div>

        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
        <br />
        <br />
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

    </div>
    </form>
</body>
</html>

これは Default.aspx.cs です。

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BiLab
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Label1.Text = "Button 1 Pressed.";
        }
    }
}

これは私の Web.Config です:

<?xml version="1.0"?>
<configuration>
  <appSettings/>
  <connectionStrings/>
  <system.web>
    <compilation debug="false"/>
    <pages enableViewState="true"/>
    <sessionState cookieless="UseCookies" cookieName="MyWebApp" timeout="20" />
    <authentication mode="Windows" />
    <customErrors mode="Off"/>
  </system.web>
</configuration>
4

2 に答える 2

1

コードビハインドで名前空間を確認してください。これは、Default.aspxのBILabおよびInherits="MyWebApp._Default"属性と一致しません。

于 2012-04-07T03:14:09.223 に答える
0

変化する:

<%@ Page Language="C#" 
         AutoEventWireup="true" 
         CodeBehind="Default.aspx.cs" 
         Inherits="MyWebApp._Default" %>

に:

<%@ Page Language="C#" 
         AutoEventWireup="true" 
         CodeBehind="Default.aspx.cs" 
         Inherits="BILab._Default" %>
于 2012-04-07T03:18:26.747 に答える