Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 717363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:24:17+00:00 2026-05-14T05:24:17+00:00

I am attempting to construct my own date picker using code from several sources.

  • 0

I am attempting to construct my own date picker using code from several sources.

Why won’t the calendar hide when visible?

myDate.ascx

<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="myDate.ascx.vb"
    Inherits="Website.myDate" %>

<asp:TextBox ID="dateText" runat="server" > </asp:TextBox>
<asp:Button ID="dateBtn" runat="server" UseSubmitBehavior="false" Text="x" />
<asp:Calendar ID="dateCal" runat="server" ></asp:Calendar>

myDate.ascx.vb

Partial Public Class myDate
    Inherits System.Web.UI.UserControl

    Protected Sub dateCal_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs) Handles dateCal.SelectionChanged
        dateText.Text = dateCal.SelectedDate ' Update text box'
        dateCal.Visible = False              ' Hide calendar'
    End Sub

    Protected Sub dateCal_VisibleMonthChanged(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MonthChangedEventArgs) Handles dateCal.VisibleMonthChanged
        dateCal.Visible = True ' For some reason, changing the month hides the calendar (so show it)'
    End Sub

    Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        dateCal.Visible = False ' Hide calendar on load'
    End Sub

    Protected Sub dateBtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles dateBtn.Click
        dateCal.Visible = Not dateCal.Visible ' On button press, toggle visibility'
    End Sub
End Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T05:24:17+00:00Added an answer on May 14, 2026 at 5:24 am

    First of all, if you want to toggle controls between page postbacks, you need to use ViewState. Check, is your page uses ViewState.

    EnableViewState for the page must be set to true in your case.

    Also, check your Page_load function.

    On every loading of the page you are hiding your calendar

    Page_load is calling every time before any button or calendar even rises.
    So, you are changing visibility to true and then using changed visibility value in events:

    dateCal.Visible = Not dateCal.Visible
    

    That’s making calendar always be visible when you are clicking on dateBtn

    To make it clear to you i will order events in your code in the order they are calling:

    Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            dateCal.Visible = False ' Hide calendar on load'
        End Sub
    
    Protected Sub dateCal_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs) Handles dateCal.SelectionChanged
            dateText.Text = dateCal.SelectedDate ' Update text box'
            dateCal.Visible = False              ' Hide calendar'
        End Sub
    
    Protected Sub dateCal_VisibleMonthChanged(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MonthChangedEventArgs) Handles dateCal.VisibleMonthChanged
            dateCal.Visible = True ' For some reason, changing the month hides the calendar (so show it)'
        End Sub
    
    Protected Sub dateBtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles dateBtn.Click
            dateCal.Visible = Not dateCal.Visible ' On button press, toggle visibility'
        End Sub
    

    Now you may see that every time when the page is loading, the page_load event is calling and hides the calendar.

    You should either set Visible=”false” in the ascx file for the calendar. Or call

    dateCal.Visible = False 
    

    only when its first loading of the page (!IsPostback property)

    so, in C# it will be

    protected void Page_Load(object sender, EventArgs args) {
       if (!IsPostback)
          dateCal.Visible = false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 364k
  • Answers 364k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need to use GUID's in single quotes - sample… May 14, 2026 at 3:35 pm
  • Editorial Team
    Editorial Team added an answer EDIT: Updated this example to work with all the examples,… May 14, 2026 at 3:35 pm
  • Editorial Team
    Editorial Team added an answer You can use a script; cscript test.js //nologo if errorlevel… May 14, 2026 at 3:35 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.