Results 1 to 4 of 4

Thread: Novice datetime picker

  1. #1

    Default Novice datetime picker

    I have an aspx page and i would like to display the datetime picker within it. This is the code that i used to display the datetime picker

    Code:
    <script type="text/javascript" language="javascript">
    
        var dp = new Ext.form.DateField({allowBlank:false,autoCreate:true});             
        dp.applyTo(Expiry.ClientID);
    </script>
    
    in the body i have
    <input id="Expiry" type="text" autocomplete="off"/>
    It is not working properly, thank you in advance

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854

    Default

    What is 'Expiry.ClientID'? You need to applyTo a DOM id, not some phantom .Net property. Also autoCreate:true and applyTo are mutually exclusive.

  3. #3

    Default

    Quote Originally Posted by tryanDLS View Post
    What is 'Expiry.ClientID'? You need to applyTo a DOM id, not some phantom .Net property. Also autoCreate:true and applyTo are mutually exclusive.
    Well i want the control do display on the form and i don't know how to do it properly. I instantiated the object and wanted to display it.

    Thanks

  4. #4
    Sencha User
    Join Date
    Apr 2012
    Location
    Austin, Texas
    Posts
    4

    Default

    The id of the control is 'Expiry' so you would have to do

    Code:
    dp.applyTo('Expiry');
    Also, note the quotes -- without those, JS thinks you are passing an object ref.

    One more thing, as you are using .NET, I assume that the input is originally a .NET TextField or something similar? In order to properly access the control's client ID, you'd have to do:

    Code:
    dp.applyTo('<%=Expiry.ClientID%>');
    ...so that the ClientID gets eval'd on the server side and then the proper id ('Expiry') will actually get rendered to your client side script. BTW, generally using the server ClientID is only necessary for nested server controls -- for controls at the top level in the page, ClientID will always be the same as the id you give it anyway.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •