Web design and hosting, database, cloud and social media solutions that deliver business results
  • Business Solutions
    • Robotic Process Automation
    • Bespoke Software
    • Database Services
      • Data Integration
      • Datawarehouse Services
      • Power BI
      • Server Upgrade and DBA Services
    • Web Services
      • Logo Design
      • Payment Gateways
      • Web Localisation and Translation
      • Web Site Optimisation
      • Web Site Security
      • Technical Tools
    • Cloud Services
      • Amazon Web Services
      • Google Cloud Services
      • Microsoft Azure
    • Microsoft 365
      • Enabling the Multi Factor Authentication Application
      • Office 365 DNS Settings Generator
    • IT Hardware
    • Social Media Services
  • Academy
    • Our Test Environment
    • Learning Databases
      • The Basics
      • Get Open Query
      • SQL Server Data
      • SQL Server Maintenance
      • Using SQL Server Dates
      • Using SQL Server Functions
      • Using SQL Server Pivot-Unpivot
      • Technical Tools
    • Learning Web Design
      • Building Ousia Content Management System
      • Using ASP-NET
      • Using CSS
      • Using JavaScript
    • Learning Cloud and IT Services
      • Task Scheduler Error 2147943645
      • Blocking Blank Senders
      • Requesting SSL and Generation of PFX file in OpenSSL Simple Steps
    • Using Social Media
      • Asking for a Google Review
      • Changing a Facebook account from personal to business
      • Choosing where to focus Social Media effort
      • Social Media Image Sizes
      • Using Meta Data to set Social Media Images
  • About
    • Blog
      • Building an entry level gaming machine
      • Google Core Update Jan 2020
      • Hot Chilli Internet Closure
      • How To Choose Content For Your Website Adverts Leaflets
      • Preventing Online Scam
      • Skimmers of the gig economy
      • The most annoying things about websites on the Internet
      • Top 5 websites for free Vector Graphics
    • Careers
      • Translator English-Japanese
      • Translator English-Portuguese
      • Translator English-Spanish
      • Translator English-Turkish
    • Portfolio
    • Regulatory
    • Team
      • Chester Copperpot
      • Gavin Clayton
      • Sai Gangu
      • Suneel Kumar
      • Surya Mukkamala
English (EN-GB)English (EN-US)हिंदी (HI)italiano (IT)日本語 (JA)Português (PT)

Using the DatePicker and Calender Extender with Mobile Devices

Using the DatePicker and Calender Extender with Mobile Devices on your website

I ran into a few issues when ing the AJAX CalenderExtender on my IPhone. It kind of works, but felt a little clunky considering there is a built in Date Picker for applications. I tend to design all of my sites as one, with selectable skins for Mobile or Desktop, so this I thought could be a bit of an issue.

Since IOS 5 Safari has had native support for HTML date tags.

Now when using a Calender Extender I have seen a lot of people run into issues after postbacks. This is due to the ViewState of the text box, and the JavaScript. I have seen numerous ways of getting around this the two main ways are to set it as read only, and the other is to insert your code inside an Update Panel. I tend to use the latter, as the user can type in the box if they want (You could add the Masked Edit Extender for example).

This is the code I use, don't forget if you use this you will need to add the Toolkit Script Manager.

HTML

<div class="ControlArea"><asp:UpdatePanel ID="UpdatePanel2" runat="server">  <ContentTemplate>  <asp:Label ID="Label1" runat="server" Text="Date To From" CssClass="LabelLeft400"><asp:Label>  <asp:TextBox id="DateFrom" runat="server" AutoPostBack="True"><asp:TextBox>  <asp:CalendarExtender ID="DateFrom_CalendarExtender" runat="server"  Enabled="True" TargetControlID="DateFrom" ClearTime="True"  PopupPosition="TopRight" Format="dd MMM yyyy">  <asp:CalendarExtender>  <asp:TextBox id="DateTo" runat="server" AutoPostBack="True"><asp:TextBox>  <asp:CalendarExtender ID="DateTo_CalendarExtender" runat="server"  Enabled="True" TargetControlID="DateTo" ClearTime="True"  PopupPosition="TopRight" Format="dd MMM yyyy">  <asp:CalendarExtender>  <ContentTemplate><asp:UpdatePanel><div>
In your code behind, you will need something similar to this, which turns off the Calender Extender and Auto Postback for Mobile Devices (I may extend it further to certain devices), and adds the HTML5 Input Type of Date. See W3 Schools for more info.

VB

Dim df As Date = DateSerial(Year(Today()) - 1, 1, 1)Dim dt As Date = DateSerial(Year(Today()) - 1, 12, 31)DateFrom.Text = Format(df, "dd MMM yyyy")DateTo.Text = Format(dt, "dd MMM yyyy")If Request.Browser.IsMobileDevice Then  DateFrom_CalendarExtender.Enabled = False  DateFrom.AutoPostBack = False  DateTo_CalendarExtender.Enabled = False  DateTo.AutoPostBack = False  DateFrom.Attributes.Add("Type", "Date")  DateTo.Attributes.Add("Type", "Date")ElseEnd If
And that is it, it on the IPhone and it will come up with the native date picker, and desktop devices will use the Java version. No need for additional plugins or too much code.

Author

Helpful?

Please note, this commenting system is still in final testing.

Website design by Claytabase

This is a section of code that has been modified from Ousia Content Management System code, one of the quickest and most optimised systems on the market, part of our website design services.

These are available with sites starting at around £500.

more: Responsive and fast. Web Development, Design and Hosting with Content Management System
Copyright Claytabase Ltd 2020

Registered in England and Wales 08985867

Site Links

RSSLoginLink Cookie PolicySitemap

Social Media

facebook.com/Claytabaseinstagram.com/claytabase/twitter.com/Claytabaselinkedin.com/company/claytabase-ltd

Get in Touch

+442392064871info@claytabase.co.ukClaytabase Ltd, Unit 3d, Rink Road Industrial Estate, PO33 2LT, United Kingdom

Partnered With

The settings on this site are set to allow all cookies. These can be changed on our Cookie Policy & Settings page.
By continuing to use this site you agree to the use of cookies.
Ousia Logo
Logout
Ousia CMS Loader