472,143 Members | 1,836 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,143 software developers and data experts.

Help with calendar control.

I am trying to use the calander control to pick a date and retrieve information from a database. When a date is clicked on, the page re-loads, with the selected date, gets the informatino from the database and creates a graph. The problem that I am having is that when you pick the "<" or ">" to navigate to a new month the page reloads with the current month. How do I get around this?

Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="VB" %>
  2. <script language="VB" runat="server">
  3.  
  4.     Dim MyVal1 As Boolean
  5.     Dim SelectedDate As Date
  6.     Dim testt As String
  7.  
  8.     Sub Page_Load()
  9.  
  10.         Try
  11.             MyVal1 = Convert.ToBoolean(Request("checkbox1"))
  12.         Catch
  13.             MyVal1 = True
  14.         End Try  
  15.  
  16.     End Sub
  17.  
  18.     Function GetmyDate() As String
  19.  
  20.         If Calendar1.SelectedDate.Date.ToShortDateString = "1/1/0001" Then
  21.             GetmyDate = Now.ToShortDateString
  22.         Else
  23.             GetmyDate = Calendar1.SelectedDate.Date.ToShortDateString
  24.         End If
  25.  
  26.         Calendar1.VisibleDate = GetmyDate
  27.  
  28.     End Function
  29.  
  30. </script>
  31. <html>
  32. <head id="Head1" runat="server">
  33. </head>
  34. <body scroll="auto">
  35.     <form id="form1" runat="server">
  36.         <strong><span style="font-size: 24pt"> <br /></span></strong>
  37.         <br />
  38.         The Date is: <%= GetmyDate%>
  39.         <br />
  40.         <Img ID="Image1" src="Draw_Pic.ASPX?val1=<%= MyVal1%>&val2=<%= GetmyDate%>" width=768 height=375><br />
  41.         <strong><span style="font-size: 12pt"> <br /></span></strong>
  42.         <strong><span style="font-size: 12pt"> <br /></span></strong>
  43.         <strong><span style="font-size: 12pt"><br /></span></strong>
  44.         <br />
  45.         <asp:CheckBox ID="CheckBox1" runat="server" Font-Size="12pt" style="z-index: 104; left: 121px; position: absolute; top: 539px" />&nbsp; &nbsp;<br />
  46.             <br />         
  47.             <asp:Calendar ID="Calendar1" runat="server" Font-Names="Arial" Font-Size="12pt" Height="200px" Width="200px" BackColor="WhiteSmoke" BorderColor="Black" BorderWidth="3px" DayNameFormat="FirstLetter" EnableViewState="False" style="z-index: 105; left: 12px; position: absolute; top: 570px" >
  48.                 <TodayDayStyle BorderWidth="3px" BackColor="MistyRose" BorderColor="Red" />
  49.                 <DayStyle BorderStyle="Ridge" BorderWidth="1px" BackColor="WhiteSmoke" />
  50.                 <DayHeaderStyle BackColor="DarkGray" BorderStyle="Ridge" BorderWidth="1px" BorderColor="Black" />
  51.                 <TitleStyle Font-Bold="True" BackColor="LightSteelBlue" />
  52.                 <WeekendDayStyle BackColor="#E0E0E0" />
  53.                 <OtherMonthDayStyle BackColor="Silver" BorderColor="DimGray" BorderStyle="Solid"
  54.                     BorderWidth="1px" />
  55.             </asp:Calendar>
  56.         <br />
  57.         <br />
  58.             <asp:Button ID="Button1" runat="server" Text="Button" style="z-index: 110; left: 231px; position: absolute; top: 536px" />
  59.         <br />
  60.         &nbsp;<br />
  61.     </form>
  62.  
  63. </body>
  64. </html>
  65.  
Feb 20 '07 #1
1 1734
jhardman
3,406 Expert 2GB
I may be way off, you write in a bit of a different style than I, but it looks like you load the page and then ask which date is entered. In the getmydate function you need to refer to the date picked on the last screen, not the current one. I would have the link look something like this:
Expand|Select|Wrap|Line Numbers
  1. <%
  2. dim prevDate, nexDate
  3. prevDate = dateAdd("m", -1, date)
  4. nexDate = dateAdd("m", 1, date)
  5. %>
  6. <a href="thispage.asp?myDate=<%=urlEncode(prevDate)%>">&lt;</a>
  7. <a href="thispage.asp?myDate=<%=urlEncode(nexDate)%>">&gt;</a>
  8.  
and then the page that opens it should say:
Expand|Select|Wrap|Line Numbers
  1. dim getMyDate
  2. getMyDate = date
  3. if request("myDate") <> ""  then getMyDate = request("myDate")
  4.  
Feb 20 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Tim Graichen | last post: by
1 post views Thread by bill yeager | last post: by
reply views Thread by maxrawson | last post: by
2 posts views Thread by Caesar Augustus | last post: by
reply views Thread by Pavan | last post: by
3 posts views Thread by =?Utf-8?B?UGFycm90?= | last post: by
7 posts views Thread by John Kotuby | last post: by
6 posts views Thread by thorpk | last post: by
7 posts views Thread by William (Tamarside) | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.