Click to See Complete Forum and Search --> : me again....


franky_25
September 2nd, 2004, 09:26 AM
hey ppl,
me back again.
I managed to design a drop down calendar control which on the click of a button gets display and on clicking the control textbox gets filled with teh selected date.But if i try to move months using < or > key the calnedar dissapears n then i have to click on the vuttin again to make it appear.Any idaeas as to have to not have it dissapeared wen the < and > are clicked????
Heres the code...

....
....
<HEAD>
<title>disp</title>
<meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<script language="javascript">
function OnClick()
{

if( divCalendar.style.display == "none")
divCalendar.style.display = "";

else
divCalendar.style.display = "none";
}
</script>
</HEAD>

....
...
....


<TD style="WIDTH: 281px; HEIGHT: 48px"><asp:label id="Label5" runat="server">txtbirthdate</asp:label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:textbox id="txtbirthdate" runat="server" Width="120px"></asp:textbox><INPUT onclick="OnClick()" type="button" value="..."><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<div id="divCalendar" style="DISPLAY: none; POSITION: absolute"><asp:calendar id="Calendar1" runat="server" Width="198px" Height="180px" CellPadding="4" DayNameFormat="FirstLetter" BorderStyle="Outset" BorderColor="#999999" Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" BackColor="White" BorderWidth="2px">
<TodayDayStyle ForeColor="Black" BackColor="#CCCCCC"></TodayDayStyle>
<SelectorStyle BackColor="#CCCCCC"></SelectorStyle>
<NextPrevStyle VerticalAlign="Bottom"></NextPrevStyle>
<DayHeaderStyle Font-Size="7pt" Font-Bold="True" BackColor="#CCCCCC"></DayHeaderStyle>
<SelectedDayStyle Font-Bold="True" ForeColor="White" BackColor="#666666"></SelectedDayStyle>
<TitleStyle Font-Bold="True" BorderColor="Black" BackColor="#999999"></TitleStyle>
<WeekendDayStyle BackColor="#FFFFCC"></WeekendDayStyle>
<OtherMonthDayStyle ForeColor="#808080"></OtherMonthDayStyle>
</asp:calendar></div>
</TD>





....
Private Sub Calendar1_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged

txtbirthdate.Text = Calendar1.SelectedDate.ToShortDateString()
Dim div As System.Web.UI.Control = Page.FindControl("divCalendar")

If TypeOf div Is HtmlGenericControl Then
CType(div, HtmlGenericControl).Style.Add("display", "none")
End Sub

MRutledge
September 2nd, 2004, 05:00 PM
It looks like the problem is that you are not keeping track of wheather or not the calendar is being shown or not between post backs. So what is happening is when you click on ">" or "<" the server posts back and the defualt of the div element is DISPLAY: none. What you would need to do is on post back if the clicked "<" or ">" then you need to set the display element to nothing.