Managing calendars in asp.net c #

I have a text box and a calendar in my asp.net web application.

I want that when you select a date in the calendar, the date / month / year of that date will be displayed in the text box.

I am new to asp.net. Can someone help me, his will will be more useful for my project.

thank

+3
source share
6 answers

in the .aspx file

<form id="form1" runat="server">
<div>
    <asp:Calendar ID="Calendar1" runat="server" OnSelectionChanged="Calendar1_SelectionChanged">
    </asp:Calendar>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></div>
</form>

in the .aspx.cs file

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
    TextBox1.Text = Calendar1.SelectedDate.ToString();
}
+6
source

Always use Google before asking a question: http://www.google.co.in/search?q=asp.net+%2B+calander+control+%2B+textbox&ie=utf-8&oe=utf-8&aq=t&rls=org .mozilla: en-US: official & client = firefox-a

check the answer below

private void Calendar1_SelectionChanged(System.Object sender, System.EventArgs e)
{
    TextBox1.Text = Calendar1.SelectedDate;
}

or

OnClientDateSelectionChanged. CalendarExtender Javascript

+1

, onselectionchanged, , ,

<asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <asp:Calendar ID="Calendar1" runat="server" 
        onselectionchanged="Calendar1_SelectionChanged"></asp:Calendar>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</asp:UpdatePanel>

, ,

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
    TextBox1.Text = Calendar.cal.SelectedDate.ToString();
}
0

"SelectionChanged" ,

txtbox.Text = Calendar1.SelectedDate;

txtbox.Invalidate();
0
<asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <asp:Calendar ID="Calendar1" runat="server" 
        onselectionchanged="Calendar1_SelectionChanged"></asp:Calendar>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</asp:UpdatePanel>
0

All Articles