J
Jeff
hi
asp.net 3.5
I'm trying to create a drop down calendar. It's based on this article I came
across on the Internet.
The problem is that when I click on the arrows to select previous or next
month, the calender disappear. So in my webpage where I use this control I
have to open the calendar again.. That doesn't look good. I think the
problem has something to do with postback and state. I'm not sure how to fix
this...
you got any suggestions?
Here is the markup:
<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="CalendarControl.ascx.cs" Inherits="Controls_CalendarControl" %>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<input id="Button1" type="button" value="..." onclick="OnClick()" /><br />
<div id="divCalendar" style="display:none; position:absolute;">
<asp:Calendar ID="Calendar1"
runat="server"
BackColor="gray"
OnSelectionChanged="Calendar1_SelectionChanged"
OnVisibleMonthChanged="Calendar1_MonthChanged" ></asp:Calendar>
</div>
<script type="text/javascript" >
function OnClick()
{
var cal = document.getElementById("divCalendar");
if (cal.style.display == "none")
{
cal.style.display = "";
}
else
{
cal.style.display = "none";
}
}
</script>
*****************************************************
Here is the code
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Controls_CalendarControl : System.Web.UI.UserControl
{
DateTime _selecteddate;
public DateTime SelectedDate
{
get { return _selecteddate; }
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
TextBox1.Text = Calendar1.SelectedDate.ToShortDateString();
_selecteddate = Calendar1.SelectedDate;
System.Web.UI.Control div = Page.FindControl("divCalendar");
if (typeof(HtmlGenericControl))
}
public DateTime Value()
{
if (TextBox1.Text.Length == 0)
return DateTime.MinValue;
else
return Convert.ToDateTime(TextBox1.Text);
}
protected override void Calendar1_MonthChanged(object sender,
MonthChangedEventArgs e)
{
// //this.Calendar1.
}
}
asp.net 3.5
I'm trying to create a drop down calendar. It's based on this article I came
across on the Internet.
The problem is that when I click on the arrows to select previous or next
month, the calender disappear. So in my webpage where I use this control I
have to open the calendar again.. That doesn't look good. I think the
problem has something to do with postback and state. I'm not sure how to fix
this...
you got any suggestions?
Here is the markup:
<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="CalendarControl.ascx.cs" Inherits="Controls_CalendarControl" %>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<input id="Button1" type="button" value="..." onclick="OnClick()" /><br />
<div id="divCalendar" style="display:none; position:absolute;">
<asp:Calendar ID="Calendar1"
runat="server"
BackColor="gray"
OnSelectionChanged="Calendar1_SelectionChanged"
OnVisibleMonthChanged="Calendar1_MonthChanged" ></asp:Calendar>
</div>
<script type="text/javascript" >
function OnClick()
{
var cal = document.getElementById("divCalendar");
if (cal.style.display == "none")
{
cal.style.display = "";
}
else
{
cal.style.display = "none";
}
}
</script>
*****************************************************
Here is the code
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Controls_CalendarControl : System.Web.UI.UserControl
{
DateTime _selecteddate;
public DateTime SelectedDate
{
get { return _selecteddate; }
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
TextBox1.Text = Calendar1.SelectedDate.ToShortDateString();
_selecteddate = Calendar1.SelectedDate;
System.Web.UI.Control div = Page.FindControl("divCalendar");
if (typeof(HtmlGenericControl))
}
public DateTime Value()
{
if (TextBox1.Text.Length == 0)
return DateTime.MinValue;
else
return Convert.ToDateTime(TextBox1.Text);
}
protected override void Calendar1_MonthChanged(object sender,
MonthChangedEventArgs e)
{
// //this.Calendar1.
}
}