Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

asp.net calendar and database

Posted on 2014-02-27
6
Medium Priority
?
775 Views
Last Modified: 2014-03-17
1. when the page is onload, i want to automatically show the current month and next month calender. Is it possible to do that?

2. Inside of the calendar, I would like to show some data and the data comes from the sql server. How to do that? like it will be select checkout car from cars where date = 01/01/2014. so 01/01/2014 in the calender will show the car name and etc.

3. Inside of the calender, I would like to block some date ranges and  the data domes from sql database server as well. is it possible?
0
Comment
Question by:CoolDev2014
  • 3
  • 3
6 Comments
 
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 39893824
I don't know how to do this specifically on .net.  I do use fullcalendar http://arshaw.com/fullcalendar/

<link rel='stylesheet' type='text/css' href='fullcalendar.css' />
<script type='text/javascript' src='jquery.js'></script>
<script type='text/javascript' src='fullcalendar.js'></script>
$(document).ready(function() {

    // page is now ready, initialize the calendar...

    $('#calendar').fullCalendar({
        // put your options and callbacks here
    })

});
<div id='calendar'></div>

Open in new window


You simply need to create a json feed via your .net http://arshaw.com/fullcalendar/docs/event_data/Event_Source_Object/

There is a good learning curve and if you understand js/jquery it is easier.  It did take me a few times using to wrap my head around all it offers but it has a lot of great built in features.  It is also free.

Kendo http://demos.telerik.com/kendo-ui/web/calendar/index.html has .NET wrappers but the entire shabang will set you back $1000.
0
 

Author Comment

by:CoolDev2014
ID: 39893918
good free option. But need some experts telling me how to do it xml.
0
 
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 39894523
You can use an xml fee http://arshaw.com/fullcalendar/docs/event_data/events_function/
$('#calendar').fullCalendar({
    events: function(start, end, callback) {
        $.ajax({
            url: 'myxmlfeed.php',
            dataType: 'xml',
            data: {
                // our hypothetical feed requires UNIX timestamps
                start: Math.round(start.getTime() / 1000),
                end: Math.round(end.getTime() / 1000)
            },
            success: function(doc) {
                var events = [];
                $(doc).find('event').each(function() {
                    events.push({
                        title: $(this).attr('title'),
                        start: $(this).attr('start') // will be parsed
                    });
                });
                callback(events);
            }
        });
    }
});

Open in new window


If you want to select a day or event such http://arshaw.com/fullcalendar/docs/mouse/
$('#calendar').fullCalendar({
    dayClick: function(date, allDay, jsEvent, view) {

        if (allDay) {
            alert('Clicked on the entire day: ' + date);
        }else{
            alert('Clicked on the slot: ' + date);
        }

        alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);

        alert('Current view: ' + view.name);

        // change the day's background color just for fun
        $(this).css('background-color', 'red');

    }
});

Open in new window

This gives the similar look and fee of google calendar except you are using your own data source that you control.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:CoolDev2014
ID: 39895893
thank. assume i built a web service and serving soap with xml. How to parse there in js?
I need some example. Thanks
0
 

Author Comment

by:CoolDev2014
ID: 39898797
with asp.net/c# please.
0
 
LVL 54

Accepted Solution

by:
Scott Fell,  EE MVE earned 2000 total points
ID: 39899172
ASP runs on the server, javascript/jquery run on the client so the two do not meet.

On line 4 http:#a39894523 you just need to switch out the url with your own url

Lines 8 & 9 are the data you are sending.  The end result is the same as myxmlfeed.php?start=1393799271&end= 1393885664000.  You can send the date time in any format you want, the sample is in unix time.  However, your date/time you send back needs to be in unix time. If that is not possible, you can convert it on line 16 using javascript http://www.epochconverter.com/programming/
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question