Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I need to select only year to textbox from datepicker or year picker. But cannot do that. i searched lot. please help me.

What I have tried:

i searched lot. please help me.
Updated 16-May-18 20:38pm
Comments
F-ES Sitecore 17-May-18 4:30am    
What datepicker are you using? What year picker? Do you want this to happen server-side via a post back? Do you want it client-side via ajax? Is the target textbox an asp:Textbox or an input element?

You need to post the relevant bits if your mark-up\code, what you've posted isn't enough to help.
Afzaal Ahmad Zeeshan 17-May-18 4:34am    
If a complete date is being provided, capture the date and get the year from it.

1 solution

The idea can be as simple as following-
1. You can get a date value from the calendar
2. Then just extract the year from that using Year property.

Example:
If you are using ASP.Net calendar control,
C#
int requiredYear = Calendar1.SelectedDate.Year;


If this approach doesn't work for you, please share what you have tried so that we will try to suggest, why that doesn't work.

Thanks.
 
Share this answer
 
Comments
I need like this demo.
http://demo.itsolutionstuff.com/demo/demo-bootstrap-year-picker-example-using-datepicker-jsexample.html
Suvendu Shekhar Giri 17-May-18 6:54am    
For that, probably you have to create this from scratch for asp.net.
do you know how to do that. THanks your reply

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900