ASP User Control Issue

Posted by Steven on Stack Overflow See other posts from Stack Overflow or by Steven
Published on 2010-04-08T19:55:22Z Indexed on 2010/04/08 20:03 UTC
Read the original article Hit count: 375

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about ASP.NET