2

以下のコードは、将来の日付を検証するために使用されていますが、機能していません。どんな助けでも感謝します。テキストボックスには読み取り専用プロパティがfalseに設定されているため、テキストボックスの値を変更して将来の日付に変更できます。その条件を検証する必要があります

// aspx で

  <asp:TextBox ID="txtdob" runat="server" OnClientDateSelectionChanged="checkDate"></asp:TextBox>

  <asp:Button ID="Button2" runat="server" onclick="Button2_Click" Height="26px" Width="23px" Text=".." />   
<script type="text/javascript" >
function checkDate(sender, args) 
{
    if (sender._selectedDate > new Date())
    {
        alert("You cannot select future date!");
        sender._selectedDate = new Date();
        // set the date back to the current date
        sender._txtdob.set_Value(sender._selectedDate.format(sender._format))
    }
}
</script>
<asp:Calendar ID="Calendar1" runat="server" onselectionchanged="Calendar1_SelectionChanged" OnClientDateSelectionChanged="checkDate"
   style="top: 320px; left: 246px; position: absolute; height: 188px; width: 259px">
</asp:Calendar>

//C# の場合

protected void Button2_Click(object sender, EventArgs e)
{
   Calendar1.Visible = true;
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
   txtdob.Text = Calendar1.SelectedDate.ToShortDateString();
}
4

3 に答える 3

0

OnClientDateSelectionChanged is not a valid method for asp calender control. It is a method used in ajax calender control. Check this link

http://forums.asp.net/t/1922747.aspx

于 2013-09-26T09:37:19.743 に答える