[CLOSED] Datepicker help

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Datepicker help

    Hi
    I just started looking at the DatePicker, and there are some things that I cant get to work.
    *First I do not want the user to be able to choose dates before todays date. I use MinDate for that, and that does not work. Maybe im using the wrong property.
    *Second I want to be able to get the selected date in a buttonclick that is in an ajax event, and that does not work, I see no property in the datepicker that is loaded with the selected date.

    Hope you can help me with this.

    
    
    
    <ext:DatePicker ID="dpDate" runat="server" />
    
    
    
    
    <ext:Button ID="btnSearch" runat="server" Text="Search" Icon="ArrowRefresh" >
    <AjaxEvents> <Click OnEvent="btnSearch_Click"></Click></AjaxEvents> 
    </ext:Button>
    
    
    
    
    
    
    protected override void OnInit(EventArgs e){
        base.OnInit(e);
        DateTime dtDagensdatum = new DateTime();
        dpDate.MinDate = dtDagensdatum;
    }
    
    
    protected void btnSearch_Click(object sender, AjaxEventArgs e){
    
    
        pnlSearchResult.Html = dpDate.SelectedDate;
    
    
    
    
    
    
    
    
    }
    Best regards
    Mikael Jürke
  2. #2

    RE: [CLOSED] Datepicker help

    Hi Mikael,

    I've confirmed the bugs. I recently changed how the DateTime objects were getting serialized into Json, and that change appears to have affected the MinDate property.

    The second issue with the SelectedDate not posting back to the server during an AjaxEvent was fixed yesterday. The following forum post outlines the ajaxevent issue, see http://forums.ext.net/showthread.php?postid=1647.aspx.

    I'll update this thread as soon as the MinDate bug has been fixed.
    Geoffrey McGill
    Founder
  3. #3

    RE: [CLOSED] Datepicker help

    Okay great, thank you!

  4. #4

    RE: [CLOSED] Datepicker help

    The MinDate bug has been fixed and committed to svn.

    Thanks for pointing out the problem originally.*


    Geoffrey McGill
    Founder
  5. #5

    RE: [CLOSED] Datepicker help

    Hi Jurke,

    I think what you want to be doing is setting the .MinDate property to "DateTime.Today" and not "new DateTime()". The default DateTime constructor returns DateTime.MinValue and not "today", which I have to say is rather unintuitive.

    Example

    // Old
    dpDate.MinDate = new DateTime();
    
    // New
    dpDate.MinDate = DateTime.Today;
    Hope this helps solve the problem.
    Geoffrey McGill
    Founder
  6. #6

    RE: [CLOSED] Datepicker help

    Yes that helped, on the MinDate issue. Thanks!

    But I still get an error when trying to get the SelectedDate property in an AjaxEvent onclick event. It says "Run time error in Microsoft JScript: 'nul' is null or is not an objct". This was a translation from the swedish error message. and points to the code in coolite.axd


    this.value=B.clearTime(true
    Best regards
    Mikael
  7. #7

    RE: [CLOSED] Datepicker help

    I'm not sure what's happening in your sample. Can you post a simplified code sample demonstrating how to reproduce the error?

    I made the following sample and it appears to work as expected.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register assembly="Coolite.Ext.Web" namespace="Coolite.Ext.Web" tagprefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            this.DatePicker1.MinDate = DateTime.Today;
        }
    
        protected void Button1_Click(object sender, AjaxEventArgs e)
        {
            this.Panel1.Html = this.DatePicker1.SelectedDate.ToString();
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ScriptManager ID="ScriptManager1" runat="server" />
            
            <ext:DatePicker ID="DatePicker1" runat="server" />
            
            <ext:Button ID="Button1" runat="server" Text="Submit">
                <AjaxEvents>
                    <Click OnEvent="Button1_Click" />
                </AjaxEvents>
            </ext:Button>
            
            <ext:Panel ID="Panel1" runat="server" Height="300" Width="300" Title="Title" />
        </form>
    </body>
    </html>
    Does your Page compile? I ask because in the code sample you posted you are setting the .Html property (string) of a Panel with the .SelectedDate property (DateTime) of the DatePicker. I would expect that code to throw an Exception even before the initial Page_Load.

    You should set the .Html property with a string.

    Example

    pnlSearchResult.Html = dpDate.SelectedDate.ToString();
    Hope this helps.
    Geoffrey McGill
    Founder
  8. #8

    RE: [CLOSED] Datepicker help

    Hi
    Thank you for your response! you are right, your example works great. It took me a while to figure out why my code did not work. The error occur when I add MS script manager. Se my exaple. It is exactly like yours but with the ms script manager.

    
    
    
    
    <%@ Page Language="C#" EnableEventValidation="false" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test_Default" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1 transitional.dtd">
    
    
    <script runat="server">
    protected override void OnInit(EventArgs e)
    {
    base.OnInit(e);
    this.DatePicker1.MinDate = DateTime.Today;
    }
    
    
    protected void Button1_Click(object sender, AjaxEventArgs e)
    {
    this.Panel1.Html = this.DatePicker1.SelectedDate.ToString();
    }
    
    
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head id="Head1" runat="server">
    <title></title>
    </head>
    <body>
    <form id="form1" runat="server">
    <ext:ScriptManager ID="ScriptManager1" runat="server" />
    <asp:ScriptManager ID="ScriptManager2" runat="server">
    </asp:ScriptManager>
    <ext:DatePicker ID="DatePicker1" runat="server" />
    <ext:Button ID="Button1" runat="server" Text="Submit">
    <AjaxEvents>
    <Click OnEvent="Button1_Click" />
    </AjaxEvents>
    </ext:Button>
    <ext:Panel ID="Panel1" runat="server" Height="300" Width="300" Title="Title" />
    </form>
    </body>
    </html>
    Best regards
    Mikael Jürke


  9. #9

    RE: [CLOSED] Datepicker help

    Hi
    Geoffrey, can you please get back to me about this bug?
    I really need to know if you are able to fix this.

    Best regards
    Mikael
  10. #10

    RE: [CLOSED] Datepicker help

    Hi Mikael,

    I'm working on a fix right now. This is a bug (defect) in both ExtJS and MicrosoftAJAX. Unfortunately the two wrongs don't cancel each other out. Hopefully a fix will be available shortly.


    Geoffrey McGill
    Founder
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] DatePicker day highlighted
    By methode in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jan 13, 2012, 10:32 AM
  2. [CLOSED] DatePicker:
    By RomualdAwessou in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Jul 09, 2010, 2:50 PM
  3. [CLOSED] DatePicker: drop
    By RomualdAwessou in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jun 28, 2010, 7:27 PM
  4. [CLOSED] datepicker from to example
    By LeeTheGreek in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Apr 04, 2010, 2:29 PM
  5. [CLOSED] DatePicker
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Dec 18, 2008, 4:31 AM

Posting Permissions