This is a migrated thread and some comments may be shown as answers.

DatePicker with regular textbox

3 Answers 151 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Li Zhou
Top achievements
Rank 1
Li Zhou asked on 08 Jul 2010, 03:50 AM
For some reason, I cannot use DatePicker control.  I can use a regular textbox, plus a caledar icon.  I want to achieve the same thing as DatePicker, by clicking that icon, it shows a calendar, when a date is slected, the date is entered into the textbox.

Is that a easy way to do this?

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 Jul 2010, 07:30 AM
Hello,


One way to achieve the functionality is using a calendar control and setting the visibility from client side on clicking the popup image. Check the following code:

aspx:
<div>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <img src="../../Images/popup.gif" onclick="openPopup();" />
    <telerik:RadCalendar ID="RadCalendar1" runat="server">
        <ClientEvents OnDateSelected="OnDateSelected" />
    </telerik:RadCalendar>
</div>


client code:
<script type="text/javascript">
    function pageLoad() {
        var calendar = $find('<%= RadCalendar1.ClientID %>');
        calendar.set_visible(false); // Initially set the visibility as false
    }
    function OnDateSelected(sender, args) {
        var dt = new Date();
        //args.get_renderDay().get_date()
    }
    function openPopup() {
        var calendar = $find('<%= RadCalendar1.ClientID %>');
        calendar.set_visible(!calendar.get_visible());
        // Read the textbox value and set the Date of Calendar
    }
</script>



-Shinu.
0
Li Zhou
Top achievements
Rank 1
answered on 08 Jul 2010, 11:30 PM
Thanks, that works well
0
Ron Boehm
Top achievements
Rank 1
answered on 16 Jul 2010, 02:00 PM
The solution provided is non-functional for me.

I am able to remove the textbox and connect the calendar to the combobox.

The problems are:
    The calendar icon is in a dev and puts extra space around it in the GUI.
    On startup, the calendar flashes on and then off and the space it took up is not removed,
        so there is a big whole in my GUI.

Tags
Calendar
Asked by
Li Zhou
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Li Zhou
Top achievements
Rank 1
Ron Boehm
Top achievements
Rank 1
Share this question
or