2012-04-07 3 views
1

ASP.NET C#을 사용하여 간단한 웹 사이트를 구축했습니다.ASP.NET C# 단추 OnClick 응답 없음, 값 변경 없음

Visual Studio에서 [RUN]을 누른 후 정상적으로 실행됩니다.

그러나 웹 호스팅 서버에 업로드 한 후에는 버튼을 클릭해도 아무런 변화가 없습니다. "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> 

답변

1

확인하여 코드 네임 스페이스. 그것은 : BILab 과 Default.aspx의 Inherits = "MyWebApp._Default"속성이 일치하지 않습니다.

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" %>