I'm working in C# / ASP.NET 3.5 and want to enable users to enter their date-of-birth. I've tried the asp:Calendar web control for this, and also considered using the jQuery-UI datepicker, and reviewed suggestions from this question.
All those options don't seem to have the "mode" I want though. I do not want an actual calendar to pop up, but just a Day/Month/Year dropdown. My requirements:
Just three dropdowns, for day/month/year
Ability to set a min and max year
Client side solution for helping pick a valid date (so don't allow 30 + February)
Nice to have: culture based position switch for day/month and month/day
Can anyone suggest such a control? Or should I just move on and build it myself?
Jeroen, there is no built in control.
The simple way to do this is add 3 drop down lists and add all months / years (Those are the simple ones). Days change, so either you can statically add 31 and do some checking, or use a database that holds a bunch of dates and use that as the datasource.
I used a jQuery add in that handled this for me, I was able to update a hidden field that could be read from ASP.Net code behind, sorry I can't remember the exact plug-in but if you search on the jQuery site you should find it (I had a quick look but couldn't track it down, jQuery site search is pants).
jQuery's datepicker might be what you want:
http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/
Related
I am using ASP.NET and Razor to create a calendar application similar to Google calendar and was hoping to get some feedback on my design thus far. My idea is to have 2 tables, one normal table for users, and another for a table of events which will store the users id and the time of the event, event ID, name of the event, and duration of the event.
I plan to write some code that will display a calendar on screen and allow the user to select multiple times so as to mark them as busy and give them a name. When this is done, the user submits the information and it is inserted into the database.
What is the best way to go about tackling this calendar construct? I can't really think of a simple way. I am guessing I can create a nice looking calendar using HTML and CSS, and perhaps JS to allow the drag and drop functionality? I suppose when the user selects a time, an object would be created with a start time and default duration, then when they drag it the duration changes. I am confused by how you would do this however, pulling objects out of thin air. How does Google Calendar do this?
And then how do you store all of the created objects in the database? I am guessing that Razor has a foreach construct and that I could just iterate over all objects created and insert them into the database one-by-one?
Also, how could I clean up the database, garbage collecting events that have already transpired while keeping events that are constant ie daily/weekly?
Apologies if the question is vague, if it is too vague then please press me on details I can be more clear on rather than close this. Thank you.
What is the best way to go about tackling this calendar construct?
If you are wondering about data structure here, whatever you do, do it in that way that it makes it compatible with standard iCalendar standard
I can't really think of a simple way.
Calendars are quite complex applications, there is no simple way. (events, sharing events, tentative, attendants, reminders...)
I am guessing I can create a nice looking calendar using HTML and CSS, and perhaps JS to allow the drag and drop functionality?
Yes.
I suppose when the user selects a time, an object would be created with a start time and default duration, then when they drag it the duration changes. I am confused by how you would do this however, pulling objects out of thin air. How does Google Calendar do this?
You can find some existing jquery plugins for this (try with this for start, or take a look at this list).
And then how do you store all of the created objects in the database? I am guessing that Razor has a foreach construct and that I could just iterate over all objects created and insert them into the database one-by-one?
Check out these jquery plugins and see how do they communicate with the server side. You will end up making ajax requests and then making database queries in the database. Razor has nothing to do with database...also Razor has nothing to do with client side interaction, it just renders page and everything else is on the js side.
Also, how could I clean up the database, garbage collecting events that have already transpired while keeping events that are constant ie daily/weekly?
I would't delete anything from database...don't see a reason for that. Just grab all you have and fill in the calendar. User will always look at month/date/week...grab data for that period and show it. When he goes back one year, he will have all the data still available.
Have you met my friend, Google?
In particular, 4GuysFromRolla has a tutorial, and there is a nice looking open source calendar control with some tutorials that should get you well on your way.
I have 15 web pages that has the same labels. But, in one case, I need to change all of their Text, in all pages. Other than writing them all by one, I want to make something general and public that I can use in all the pages. The ID's of the labels are same. I don't know how to do it with different web pages. Can you give me a hint? I don't know if its called Utility or Dictionary. A friend of mine mentioned it a few mins ago but I don't want to ask her again she already thinks I am dumb :(
They are ASP.NET pages with C# also I am using Devexpress.
I want to change only one web page at a time. But use the method for all web pages when they are shown (by the user). Not changing all the 15 at the same time.
If the informations shown on the labels are the same for every user, you could use the ASP.NET Cache.
How to: Add Items to the Cache
How to: Retrieve Values of Cached Items
If not, you could use the Session.
But normally you would use a dbms for this purpose, for example SQL-Server.
Note: Do not use the Label's ID as Keys for the Cache/Session/Database but the meaning. ID's may change, apart from that it's much more readable.
I use aspnet 4 and c#.
My user need inserting DATE and TIME in a field.
The data to pass to DataBase has this format
2011-02-23 10:30:29.27 and DataType: datetime2
I can see in visual studio just a Calendar WebControl but it is able to handle just the date and not the time.
I found an interested WebControl at:
http://demos.telerik.com/aspnet-ajax/calendar/examples/overview/defaultcs.aspx
Specially functuion for Time Picker.
My question do you know any Free/Open source control?
If not any other solution WebControl or not?
Thanks
I don't know if you are willing to use jQuery UI. If you are, Trent Richardson has extended the jQuery UI DatePicker to include a TimePicker.
This might work for you: http://trentrichardson.com/examples/timepicker/
There are a lot of sample on the page so it sould be pretty easy to use and you can wire up to your asp.net backend a number of ways including a static webmethod exposed via a scriptmanager.
Hope this helps.
I have a database that stores an arbitrary number of phone numbers. There are a few pages that (should) allow admins to change these numbers and add them.
I plan to create a custom control that will:
Show all existing numbers
Provide an edit button
In Edit mode, will show an add button
Have an add button that adds the requisite fields in a way that does not cause a postback.
Provide a save button (of course)
These seems like a complicated task. I've done a bit of research, but haven't found any ready-made solutions. Is there anything I should have spotted or should know before I go about writing this from scratch?
I've built something like this using jQuery. Use a table to display the phone numbers. Then, jQuery excels at being able to hook into button presses and manipulate elements on the page (wrap a table cell's contents with an input box, or add add a table row) without causing a postback, completely aside from any server-side ASP.NET controls. Then, on Save you can stuff the phone numbers into an <input type="hidden runat="server"> in a delimited format (e.g., "212-555-1212|617-555-1212") and let the Save button do a regular postback.
You could probably find a commercial datagrid control with Ajax features to enable editing and add rows but you'd probably spend as much time customizing it as you would writing it from scratch with jQuery. It's the sort of thing you've seen dozens of places but everyone does it a little different.
I've never seen a custom control that worked specifically like that. I'd search on CodeProject to see if a custom control exists before writing one.
Are the existing numbers in a variety of formats? For example: 123-456-7890 and (123) 456 7890? If so, you may have to decide in advance on the format you are going to use and then run a script to clean up the existing records. I would use JQuery as suggested by Marc to enhance the editing experience. Validation will have to be precise.
I have some questions regarding calendars
Is there any good calendar generates for either asp.net mvc or jquery. I would like to find something that can make calendars and have features like this.
Generates all the months (but of course only features the current month that is being displayed)
If the name of the calendar event is too long it cuts it off and if you click on it a popup comes showing you the full description
Ability to add a new task to the calendar. So when you click on it pops up a dialog box and you can fill out information.
So basically what Google calendar can do. You can add a task then it pops up with like where, time notifications area.
So is there any sort of solution like this for .net MVC or jquery? If not then I am willing to use other javascript frameworks if needed but rather not.
I checked out http://arshaw.com/fullcalendar/ and it really does not have everything I need.
I like this one http://www.redredred.com.au/projects/jquery-week-calendar/
Since it almost does what I want but the major draw back this is that it only does weeks not a full month.
Is there some sort of library that I can use to easily import google calendar data in, outlook calendar data in and basically any major calendar program.
I know that icalendar is like the standard format so is there a C# library that will like parse this stuff?
I going to need to store the calendar data in a database. How would the database table look like?
I think that for the client side, you are asking for a little too much, to be honest. Your best bet is find the one that does the most that you want out-of-the-box but has enough customization to allow for you to fill in the functionality you are looking for. Either that, or write the code from scratch. To be honest, you are rendering a table with some jQuery on the front end for client-side events. It's tedious, but shouldn't be overly difficult.
As for a .NET library to handle calendar formats, I recommend DDay's iCal. It has some issues and requires some understanding to get running, but it works (I use it myself for a site that I project iCalendar entries from).
As for the calendar in the database, that's really up to you. The minimal amount of information you need is a date field, obviously. I'd recommend something with an offset (SQL Server 2008 has the datetimeoffset) since you might want to take into account time zones. Beyond that, any information you want to store is up to you.
In response to chobo2's comment about how to get the data to appear in the appropriate column, when you render the table, you are going to have a 7 x 5 table (seven days, five rows). I would suggest tagging each of them with the date.
Then, as you render your table, when you render the cell, you look to see if you have any events for your date, if you do, then render the cell appropriately.
Why don't you start slightly less ambitiously? Google has a large team working on their calendar and for you to hope to replicate that without taking years will just end up with an unfinished project.
1
You said you didn't like FullCalendar but it does support 95% of the features you need from the calendar, minus actually clicking on days to add events.
FullCalendar is great for displaying
events, but it isn't a complete
solution for event content-management.
Beyond dragging an event to a
different time/day, you cannot change
an event's name or other associated
data. It is up to you to add this
functionality through FullCalendar's
event hooks
You get a dayClick event which you could use to add an event. I wouldn't bother though going this route though, and simply have a separate panel on the page with a text box for the name, a small icon which makes a Jquery UI calendar appear. It sounds low-tech but the pain of getting the click event working in all browsers would be a big task.
This textbox displays the full event name when you click on day which gets around your long text cropping issue. Alternatively this shows you a nice static html iCal-like solution which you may have looked at already.
Generating a month calendar for the year could be done statically using HTML instead of using jQuery.
2
If you stick to the iCalendar format for Outlook and Google, which both support it, then it's very easy to write a parser for that format as it's such a simple text format. This question has more details on making one, you could use an existing library for it.
3
A simple table of equivalent SQL types like below will be enough:
Events
Id
Name
Location
DateTime Start
DateTime End
bool IsRecurring
Recurring events will be the hardest part because of the calculations you have to perform to work out the next event. You don't store each occurrence in the database. Using the epoch for the calculations might help out, it's a technique Exchange uses.