Inhoud blog
  • ASP.NET - Asynchronous call to a webservice with impersonation
  • ASP.NET - Custom object as parameter for ObjectDataSource
  • ASP.NET - Identity impersonation
  • MyCalendar - add events without postbacks
  • ASP..NET Web Parts
    Zoeken in blog

    My Profile
  • LinkedIn
  • My Favorite Blogs
  • Kevin DeRudder
  • Rudi Larno
  • David Hayden
  • David Cumps
  • Reinout's blog
    Talking about new features, useful things, frustrations in .NET and so on...
    22-08-2007
    Klik hier om een link te hebben waarmee u dit artikel later terug kunt lezen.MyCalendar - add events without postbacks
    Most of the time a calendar is used to simply select a date, in some cases it will be stretched to give an overview of a schedule, getting the same look and feel as MS Outlook.

    Now, what if you want to be able to add an event to a date ?

    First drop a calendar control on your web user control or web page, be sure to stretch it in a similar way as below.
    Add a div containing one or more fields to insert info of the new events.

    E.g.



    Next step is to add 3 javascript functions :
    •    HideTaskPane
    •    ShowAddTaskPane
    •    ReceiveServerData

    HideTaskPane will simply hide the div.

    ShowAddTaskPane accepts 2 parameters, eventargs and the selected date. The function will display the task pane (the div) and call the server (by using a callback eventhandler, see later) to store the selecteddate, e.g. in the viewstate.

    ReceiveServerData is called after the callback eventhandler, this can be used to display the data received from GetCallbackResult() (again, see later).


    Now, moving to the C# (or VB.NET) code :

    Don’t forget to inherit from ICallBackEventHandler (in the System.Web.UI namespace).



    In the Page_Load event, register the callback script if it’s not yet registered.
    The server-side RaiseCallBackEvent method is called from the client-side “ShowAddTaskPane” function, you can add the selected date to the viewstate and/or perform some other actions here.
    GetCallBackResult can be used for testing purpose (e.g. return the selected date from the viewstate) or to return data from the server to the client.



    Last step is to add code in the DayRender event of the calendar. This is the place in which you can add controls to a day.
    This sample code will add events from a list of AgendaItem’s.
    Literals can be used to insert crlf’s, labels to add existing events.
    An HtmlAnchor is used as a link to display the task pane, calling “ShowAddTaskPane” on click.



    22-08-2007 om 09:51 geschreven door Reinout Waelput  




    Archief per week
  • 03/09-09/09 2007
  • 27/08-02/09 2007
  • 20/08-26/08 2007
  • 13/08-19/08 2007
  • 06/08-12/08 2007
  • 26/09-02/10 2005

    E-mail mij

    Druk op onderstaande knop om mij te e-mailen.



    Blog tegen de wet? Klik hier.
    Gratis blog op https://www.bloggen.be - Meer blogs