Click here to Skip to main content
15,889,096 members
Articles / Web Development / ASP.NET

OneNote on iPhone and Palm Pré using Windows Azure

Rate me:
Please Sign up or sign in to vote.
4.96/5 (39 votes)
25 Dec 2009CPOL12 min read 80.5K   322   53  
Learn how to synchronize your OneNote notebooks on Windows Azure and access it from your iPhone or your Palm Pré.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Rino.iphone
{
    /// <summary>
    /// Class to display a section in a notebook
    /// </summary>
    public partial class section : System.Web.UI.Page
    {
        /// <summary>
        /// Load page event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            // Get notebook id
            string notebookid = Request.QueryString["notebookid"];
            if (notebookid == null)
            {
                sectionlist.AddItem("No notebook");
                return;
            }

            // Load notebook
            Notebook notebook = AzureStorage.LoadNotebook(notebookid);
            if (notebook == null)
            {
                sectionlist.AddItem("Notebook don't exist");
                return;
            }

            // Get section id
            string sectionid = Request.QueryString["sectionid"];
            if (sectionid == null)
            {
                sectionlist.AddItem("No section");
                return;
            }

            // Look for the section
            Section currentsection = null;
            foreach (Section section in notebook.Sections)
            {
                // Found ?
                if (section.ID == sectionid)
                {
                    currentsection = section;
                    break;
                }
            }

            // Section not found
            if (currentsection == null)
            {
                sectionlist.AddItem("Section not found");
                return;
            }
            sectionlist.title = currentsection.Name;

            // For each page
            foreach (PageHeader page in currentsection.Pages)
            {
                // Compute url
                string url = String.Format("/rest.svc/pages/{0}?format=html", HttpUtility.HtmlEncode(page.ID));

                // Add it to the list
                sectionlist.AddItem(page.Name, currentsection.Color, url);
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect C2S
France France
Lionel is a software architect at C2S, a software company based in France and subsidiary of the Bouygues group.
Lionel is also the author of Liogo, an open-source Logo compiler for .NET.
Lionel is a contributor of DotNetGuru and Dr.Dobb's Journal.
Lionel is President and co-founder of OLPC France.

Comments and Discussions