ASP Calendar Date Pick
Posted
by Steven
on Stack Overflow
See other posts from Stack Overflow
or by Steven
Published on 2010-04-08T17:46:10Z
Indexed on
2010/04/08
19:13 UTC
Read the original article
Hit count: 396
I am attempting to construct my own date picker using code from several sources. Specifically, I am now populating the textbox with a calendar click.
Two questions:
- Why does the first click refresh the page without doing anything?
- How can I have the textbox update without refreshing the entire page?
myDate.ascx
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="myDate.ascx.vb"
Inherits="Website.myDate" %>
<script language="javascript" type="text/javascript">
function toggleCalendar(myID) {
var obj = document.getElementById(myID)
obj.style.display = (obj.style.display == "none") ? "" : "none";
}
</script>
<asp:TextBox ID="dateText" runat="server" > </asp:TextBox>
<input type="button" name="dateBtn" value="x"
onclick="toggleCalendar('<%=dateCal.clientID%>');" />
<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.Style("display") = "none" 'hide calendar'
End Sub
End Class
© Stack Overflow or respective owner