Basic Date Picker Forums

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

Custom date text

Last post 08-03-2009, 4:44 AM by geoffrey.mcgill. 1 replies.
Sort Posts: Previous Next
  •  05-17-2009, 3:24 PM 1788

    Custom date text

    Hi,

    I would like to customize the date displayed in the textbox beyond what a format string would allow. Specifically, I want to show "Today" when the selected date is today.

    Is there any way to do this?

    Thanks.
  •  08-03-2009, 4:44 AM 1811 in reply to 1788

    Re: Custom date text

    Unfortunately I don't think this is possible.

    It is possible to change the text (client-side) based on the date, but the problems happen server-side because a "date in a certain format" is expected. Passing a string such as "Today" would not be parsed (server-side) into a date.

    Here's an example of changing the textbox string client-side using the OnClientAfterSelectionChanged event handler.

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

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

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

    <script runat="server">
    protected void Button1_Click(object sender, EventArgs e)
    {
    this.Label1.Text = this.BasicDatePicker1.SelectedDateFormatted;
    }
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml" >

    <head id="Head1" runat="server">
    <title>Basic Date Picker Example</title>

    <script type="text/javascript">
    var selectionChanged = function(sender) {
    if (sender.getSelectedDate().equals(Date.today())) {
    sender.input.value = "Today";
    }
    };
    </script>
    </head>


    <body>
    <p><a href="SelectionChanged.aspx">Reload</a></p>

    <form id="form1" runat="server">
    <BDP:BasicDatePicker
    ID="BasicDatePicker1"
    runat="server"
    OnClientAfterSelectionChanged="selectionChanged"
    />

    <br />
    <br />

    <asp:Button ID="Button1" runat="server" Text="Submit" onclick="Button1_Click" />

    <br />
    <br />

    <asp:Label ID="Label1" runat="server" />
    </form>
    </body>
    </html>



    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