Basic Date Picker Forums

Welcome to Basic Date Picker Forums Sign in | Join | Help
in Search

Calculating Time Span for Time Picker

Last post 04-24-2009, 12:00 AM by geoffrey.mcgill. 1 replies.
Sort Posts: Previous Next
  •  12-22-2008, 3:55 PM 1748

    Calculating Time Span for Time Picker

    I'm using just the Time Picker to allow clerks to select a Departure time and a Return Time.

    What I want to accomplish is to have a Textbox below that when the clerk click on the calculate button, it will calculate the time between the Departure Time and The Return Time. I then have to use that number to make another calculation for figuring costs for field trips.

    I just can't seem to get the right syntex together to so that the time will calculate. It doesn't seem to like the time span syntex.

    Any suggestions would be appreciated.

    Thanks and love the product.

  •  04-24-2009, 12:00 AM 1785 in reply to 1748

    Re: Calculating Time Span for Time Picker

    Here's a simplified code sample which demonstrates what is described above (i think).

    Example

    <%@ Page Language="C#" %>

    <%@ Register Assembly="BasicFrame.WebControls.BasicDatePicker" Namespace="BasicFrame.WebControls" TagPrefix="bdp" %>

    <script runat="server">
        protected void Button1_Click(object sender, EventArgs e)
        {
            int hours = (this.TimePicker2.SelectedTime - this.TimePicker1.SelectedTime).Hours;

            this.Label1.Text = "Total Cost: $" + (hours * 25).ToString();
        }
    </script>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server" />

            <asp:UpdatePanel ID="ContentUP" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <p>Start Time:
                    <bdp:TimePicker ID="TimePicker1" runat="server" /></p>
                   
                    <p>End Time:
                    <bdp:TimePicker ID="TimePicker2" runat="server" /></p>
                   
                    <p><asp:Button ID="Button1" runat="server" Text="Calculate" onclick="Button1_Click" /></p>
                   
                    <asp:Label ID="Label1" runat="server" />
                </ContentTemplate>
            </asp:UpdatePanel>
        </form>
    </body>
    </html>

    Hope this helps.
    Thanks,
    Geoffrey McGill
    ----------------------------------------
    Coolite Inc.
    Email: support [at] coolite [dot] com
    Phone: +1(888)775-5888
View as RSS news feed in XML
 
Powered by Community Server, by Telligent Systems