TStamper
TStamper

Reputation: 30354

asp:calendar not work correctly in MVC

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

Upvotes: 2

Views: 2086

Answers (3)

pbz
pbz

Reputation: 9085

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

Upvotes: 0

user1228
user1228

Reputation:

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

Upvotes: 7

sgwill
sgwill

Reputation: 10524

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.

Upvotes: 8

Related Questions