我可以在网页上看到日期人口。但是,它没有出现在TextBox
中。我需要选择的日历日期显示在TextBox
上。
以下是我的Default.aspx
代码:
<%@ Page Language="VB" %>
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
TextBox1.Focus()
End Sub
Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Write("You selected: " &
Calendar1.SelectedDate.ToShortDateString())
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Using the Calendar Control</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Calendar ID="Calendar1" runat="server"
OnSelectionChanged="Calendar1_SelectionChanged">
</asp:Calendar>
</div>
</form>
</body>
</html>
答案 0 :(得分:0)
更改行:
Response.Write("You selected: " & Calendar1.SelectedDate.ToShortDateString())
为:
TextBox1.Text = Calendar1.SelectedDate.ToShortDateString()