MVC maintaining dates in textboxes using datepicker - asp.net-mvc

In MVC.NET, I have one page with "To Date" and "From Date" textboxes having Bootstrap datepicker attached to them.
On page load, I want today's date selected in datepicker by default and displayed in the textbox as well.
Beside I have Go button on same page which redirects to another page which uses FromDate and ToDate filtered data.
2. On this second page I have back button of type "button" (not submit) which when clicked should return to page one with having FromDate and ToDate selected values in textboxes.
My issue is,I have set "FromDate" and "ToDate" textbox values as today's date in document.ready()
However if I select another date and click on "GO" which redirects to page two but when clicked on back button on page 2, Page one ToDate and FromDate are filled with today's date (due to document.ready())
How do I achieve to show today's date on page load and for rest of the times maintain selected Dates in textboxes when back is clicked.

Page get refreshed when you coming back on first page from second page.
So you have to carry whatever data you have entered on first page when you will hit Controller/Action you have to take this data in TempData and whenever you will come on the fist page you have to set this data again in that that text boxes.
Hope this will help you !!

Related

Is it possible to unselect the current date in jQuery UI datepicker?

I'm using a datepicker, which is always visible on the page, and tied to a hidden <input>.
Depending on the user interactions on the page, some dates can get dynamically disabled (via beforeShowDay).
The problem is, this allows to disable a date which has been previously selected:
To avoid this, I'd like to unselect the current date prior to refreshing the datepicker.
Is this possible?
EDIT: The datepicker is attached to a div. Clear the selected value like this:
$('selector').datepicker('setDate')
This will unselect whatever day is selected.

I want to save list of holidays With date and day in my 1st view. How do we do that?

I want to save list of holidays in my 1st view. I have another view (i.e, 2nd View) where am selecting the date, day and typing festival name in the textfield in that view. I want to show that selected data in my 1st View when i click on back buttono navigation bar . How do we do that??
How to show the selected data in my 1st View?? and i want to store it on phone memory
Store value festival name and selected date in NSUserDefault
Now in 1st View's view will appear which will be called when back button is presswd
if NSUserDefault has festival name and selected date then show them

jquery datepicker ui - lose hover after next previous

I have a datepicker setup as inline. The idea I have is the selected days and when you hover over a tooltip pops up and shows the title of the events.
The issue I am having is when skipping to the next month, the hover stops working, and when I click back the ones on the default (current) month do not work either.
In the example http://jsfiddle.net/welovedesign/rn67L/ there are events on the 1st and 11th of August and the 11th of September
When the calendar is created, only the dates for the current month are rendered. This is why when you click to another month that therre is no div appearing when you hover over a date with an event.
In the onChangeMonthYear event you'll need to create your div for a date where there is an event and associate it with the appropiate date (as you are doing in the beforeShowDay event).

How do I get and show results of autocomplete in other textbox

I have two textboxes and I want to use autocomplete in jQuery. I want to show the results of a search from the first textbox in the second textbox, like this :
First TextBox Second TextBox
Se.... server
serve
search
seat
.
.
.
and ...
How can I search in the first textbox and have results appear in second textbox?

ModelState.IsValid for invisible controls

I am working on MVC with C#.
I have 2 radio buttons. On selecting first radio button, a textbox will be shown which allows to enter date values.
<%= Html.TextBox("ReceivedDate")%>
on selecting the second radio button, the textbox gets hidden.
For the first time, when i select first radio button and entered date and clicked Next to navigate to next page and came back to this page again and clicked second radio button and clicked Next to continue and again i came back to this page and without changing any option click continue, its not allowing to navigate and shows an error.
A value is required.
Which means the ModelState validating the hidden controls also.
Please suggest how to control it
Instead of hiding it remove the element from the DOM and reinsert it if the first item is selected again. Another way would be to change the name of the input control to something else (a key not present in your model data) when the first item is not selected.
Validating hidden input types is a good thing, i often use them to synchronize data from complex controls (like a treeview with checkboxes). An input type with a hidden css style doesn't make it not submit with the form it belongs too.

Resources