Solved

asp.net calendar and database

Posted on 2014-02-27
6
619 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now