Results 1 to 2 of 2

Thread: Calendar Control TextBox VB.NET

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2017
    Posts
    1

    Calendar Control TextBox VB.NET

    Hello,
    I am trying to get my code to display the date I select from the calendar on the textbox.
    Below is my code... Thank you all for your kind help and pointing me to the right source.
    Warmly

    Code:
      <%@ 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>
    Name:  CALENDAR.PNG
Views: 7399
Size:  29.2 KB

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: Calendar Control TextBox VB.NET

    Welcome to VBForums

    I have moved this thread from the 'ASP, VB Script' forum to the 'ASP.Net' forum.


    In terms of your question, try adding this:
    Code:
          Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)
              Response.Write("You selected: " &
                Calendar1.SelectedDate.ToShortDateString())
              TextBox1.Text = Calendar1.SelectedDate.ToShortDateString()
          End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width