I wanted to make a simple asp.net example page with just shows "Hello, World!" and current time.
but it shows only "Hello, world!", not time. This is my code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
This is a test
</title>
<script language="VB" runat="server">
Sub Page_Load(ByVal Sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lblMessage.Text = DateTime.Now.ToString()
End Sub
</script>
</head>
<body>
<p> Hello, World! </p>
<asp Labelid="lblMessage" runat="server" />
</body>
</html>
Why does this happen and what's cure for it?
The issue is probably the malformation of the label.
Not sure why you're using a label here in the first place (typically they're used for labeling form inputs)
<asp Labelid="lblMessage" runat="server" />
Should be
<asp:Label id="lblMessage" runat="server" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.