We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How would I add a tooltip to all datepickers in a project?

Thread ID:

Created:

Updated:

Platform:

Replies:

132511 Sep 6,2017 02:17 AM UTC Sep 7,2017 01:06 PM UTC ASP.NET Core 3
loading
Tags: DatePicker
Allan Nielsen
Asked On September 6, 2017 02:17 AM UTC

Hi,
I have a large ASPNET Core project that contains a lot of date picker input fields.  I have been requested to add a tooltip that displays the selected date in the users Long Date format to all date fields.  Is it possible to do this globally?  or would I have to do add a tooltip to each field?  An chance you could provide a coded example as I am new to web development?
Thanks in advance

Berly Christopher [Syncfusion]
Replied On September 6, 2017 04:31 PM UTC

Hi Allan, 
 
Thanks for contacting Syncfusion support. 
 
We have checked with your query. We suggest to use “htmlAttributes” API to set the tooltip for the DatePicker component initially. By using this API, you can add custom attribute to the DatePicker component. Please refer the below code example. 
Index.cshtml: 
 
 
@{ IDictionary<string, object> htmlAttr = new Dictionary<string, object>(); 
    string value = "hi"; 
    htmlAttr.Add("title", value);     
} 
 
<ej-date-picker id="DatePick1" html-attributes="htmlAttr></ej-date-picker> 
       
 
Also, if you are using multiple datepicker in the page, you can achieve your requirement (“I have been requested to add a tooltip that displays the selected date in the users Long Date format to all date fields”) by using our “change” event in your application. This will update your tooltip text whenever the value changes in DatePicker component. 
 
We suggest you to use ej.format() in your sample that will used to convert the date value as the desired format. Then you have to store this date value in the private variable and set this value to the “htmlAttributes” API by using the below code example. 
Index.cshtml: 
  <ej-date-picker id="DatePick2" change="onChange"></ej-date-picker> 
  <ej-date-picker id="DatePick3" change="onChange"></ej-date-picker> 
  <ej-date-picker id="DatePick4" change="onChange"></ej-date-picker> 
<script> 
         function onChange(args) 
         { 
             var date = ej.format(this.model.value, "dddd, d MMMM, yy", this.model.locale); 
             this.option("htmlAttributes", { title: date }); 
         } 
     </script>   
                 
For your convenience, we have prepared the sample based on your requirement. Please get the sample from the below location. 
  
To know more about our API’s, events and methods please refer the below API Documentation link. 
 
Please refer the below link to kow more about our DatePicker component in ASP.NET Core. 
 
If still you are facing issues please get back to us with more details that will help us to provide exact solution. 
 
Regards, 
Berly B.C 


Allan Nielsen
Replied On September 6, 2017 11:06 PM UTC

Thank you for your quick response. Simple and well explained.


Berly Christopher [Syncfusion]
Replied On September 7, 2017 01:06 PM UTC

Hi Allan, 
Thanks for the update. Please check with the provided sample and get back to us if you need any further assistance on this. 
Regards, 
Berly B.C 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;