Solved

asp.net calendar and database

Posted on 2014-02-27
6
660 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 52

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 52

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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

856 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