ASP.NET C#で簡単なWebサイトを構築しました。ASP.NET C#ボタンOnClick応答なし、値の変更なし
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>