Label1 and the name Class1 doesn't exist in current context
Bonjour
Le code suivant donne l'erreur "Label1 doesn't exist in current context" et "the name Class1 doesn't exist in current context".
C'est un projet website.
Merci pour toute aide.
Romeo
aspx-code (oop.apsx)
Code:
1 2 3
| <%@ page language="C#" autoeventwireup="true" validaterequest="false" inherits="oopC.oop" CodeFile="oop.aspx.cs" %>
<asp:Button ID="Button1" runat="server"* />
<asp:Label ID="Label1" runat="server" ></asp:Label> * |
code-behind: (oop.aspx.cs)
Code:
1 2 3 4 5 6 7 8 9 10 11
| using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; *
namespace oopC
{ partial class oop : System.Web.UI.Page
{ protected void Button1_Click(object sender, System.EventArgs e)
{ int z;
z = Class1.test(3);
Label1.Text = z.ToString();
}
}
} |
Dans le dossier App_Code, il y a le fichier 'useclass.cs' avec ce code:
Code:
1 2 3 4 5 6 7
| public class Class1
{ public static int test(int a)
{ int x;
x = a * 2;
return x;
}
} |