主题:是否代码有错?一段很简单的代码,但我不知道是否有错
一段很简单的代码,但我不知道是否有错,我运行时,老得到以下错误提示,真的不知道是什么原因啊!!!:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0029: Cannot implicitly convert type 'string' to 'System.Web.UI.WebControls.Label'
Source Error:
Line 4: void Page_Load()
Line 5: {
Line 6: time=DateTime.Now.ToString();
Line 7: }
Line 8:
Source File: Ch01\punctual.aspx Line: 6
Show Detailed Compiler Output:
Show Complete Compilation Source:
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
原代码:
<%@ Page Language="C#" %>
<script runat="server">
void Page_Load()
{
time=DateTime.Now.ToString();
}
</script>
<html>
<head>
</head>
<body>
<form runat="server">
In WebServerLand the time is currently:
<asp:Label id = "time" runat="server"/>
<!-- Insert content here -->
</form>
</body>
</html>
Server Error in '/' Application.
--------------------------------------------------------------------------------
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0029: Cannot implicitly convert type 'string' to 'System.Web.UI.WebControls.Label'
Source Error:
Line 4: void Page_Load()
Line 5: {
Line 6: time=DateTime.Now.ToString();
Line 7: }
Line 8:
Source File: Ch01\punctual.aspx Line: 6
Show Detailed Compiler Output:
Show Complete Compilation Source:
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
原代码:
<%@ Page Language="C#" %>
<script runat="server">
void Page_Load()
{
time=DateTime.Now.ToString();
}
</script>
<html>
<head>
</head>
<body>
<form runat="server">
In WebServerLand the time is currently:
<asp:Label id = "time" runat="server"/>
<!-- Insert content here -->
</form>
</body>
</html>