tags:

views:

860

answers:

3

I have an asp:calendar on my view page and as I hover over it..it shows a javascript postback status bar. but I have an asp:button also on the same page and when I hover over it. The action from the controller is in the status bar..because I have an onClick attribute for the button that triggers an action on the server side. and in the asp:calendar I also have a trigger event OnSelectionChanged the has a method on the server side...but as I said when I hover over the calendar to pick a date in the status bar it shows:javascript:_doPostBack($ct100ContentPlaceHolder?mycalendar',''3270) and when I click a date I receive an error that says object doesnt support this method..Also mycalendar is the id name of the asp:calendar

+8  A: 

The ASP.NET Server Side controls aren't really meant to play well with MVC. The Server Side controls combine the View and the Controller in one package, whereas MVC Seperates them.

The other reason the Calendar control won't work is that it relies on the postback model, which doesn't work in MVC.

I would recommend trying a javascript Calendar control instead.

sgwill
But my asp:Button works fine and follows the onclick method that I have on the server side..and I don't know a javascript calendar control,so could you recommend the code for one?
TStamper
Yes, see this for a more thorough explanation: http://flux88.com/blog/leveraging-existing-asp-net-features-in-asp-net-mvc/
sgwill
+7  A: 

Sam's right (upvoted). Look at using jQuery in your web app. In jQuery's UI (its an additional .js file) there's a great calendar chooser (if that's what you're looking to do--choose a date). Just make sure you grab the .css file for the date picker.

jQuery: http://jquery.com/
jQuery UI: http://ui.jquery.com/
jQuery datepicker demo: http://ui.jquery.com/repository/tags/latest/demos/functional/#ui.datepicker

I think you need to get the development bundle to make sure you get the .css file for the date picker

http://ui.jquery.com/download

If you can't find the css file (I couldn't) do a search on google for ui.datepicker.css

Will
Wow! jQuery UI is great stuff!
magnifico
A: 

You could try BaseCalendar, it doesn't rely on or use postbacks.

pbz