How do you click a calendar and copy the date to a textbox without postback, in asp.net with javascript? -
i have asp.net page used searching rows of data. want able search specific date-interval, therefore have added 2 calendars (from & to) , textbox each one.
when date selected in calendar displayed in matching textbox, although causes postback, , problem.
i have never used javascript before, thought give go, exclusivly see examples using html, not using @ all. use asp.net web controls such <asp:calendar.../>
.
so code follows off top of head, know javascript totally wrong, hope understand want achieve when @ it.
<script type="text/javascript"> function calendar1_selectionchanged() { fromdate.text = calendar1.selecteddate.tostring(); } </script> <asp:calendar id="calendar1" runat="server" onselectionchanged="calendar1_selectionchanged"></asp:calendar> <asp:textbox id="fromdate" runat="server"></asp:textbox>
all answers appreciated! have been trying find answer googling, no luck..
edit: work on page, need keep textboxes. or other way date can edited manually (in datetime format)
the problem here when page served browser, it's altered have posted there. onselectionchanged
event not javascript event, postback call method calendar1_selectionchanged
@ server. javascript code, although function appears have same name onselectionchanged
event, not being run.
my recommendation use jquery datepicker.
i'm not sure javascript should work expect to. looks you're using few c# properties/methods...
Comments
Post a Comment