protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Page);

            //update local tag cache
            m_sBaseDir = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            this.UpdateTagCache();

            m_pTags    = FindViewById <EditText>(Resource.Id.txtTags);
            m_pSources = FindViewById <EditText>(Resource.Id.txtSource);

            EditText pSnippetContent = FindViewById <EditText>(Resource.Id.txtSnippetContent);
            EditText pSourceData     = FindViewById <EditText>(Resource.Id.txtSourceData);

            Button pTagsButton = FindViewById <Button>(Resource.Id.btnTagsList);

            pTagsButton.Click += delegate
            {
                this.DisplayList("tags");
            };
            Button pSourceButton = FindViewById <Button>(Resource.Id.btnSourceList);

            pSourceButton.Click += delegate
            {
                this.DisplayList("sources");
            };

            Button pSubmitButton = FindViewById <Button>(Resource.Id.btnSubmit);

            pSubmitButton.Click += delegate
            {
                string sContent = pSnippetContent.Text;
                string sTags    = m_pTags.Text + ",source:" + m_pSources.Text;

                // add meta tags
                //sContent = "<meta name='sourceTag' content='" + lblSourceName.Content + "'><meta name='source' content='" + txtSourceText.Text + "'>" + sContent;
                sContent = "<meta name='sourceTag' content='" + m_pSources.Text + "'><meta name='source' content='" + pSourceData.Text + "'>" + sContent;

                // make the xml request body
                string sBody = "<params>";
                sBody += "<param name='sTagList'>" + sTags + "</param><param name='sSnippet'>" + Master.EncodeXML(sContent) + "</param>";
                if (m_bEditing)
                {
                    sBody += "<param name='sFileName'>" + m_sEditingSnippet + "</param>";
                }
                sBody += "</params>";

                string sResponse = "";
                if (m_bEditing)
                {
                    sResponse = WebCommunications.SendPostRequest("http://dwlapi.azurewebsites.net/api/reflection/KnowledgeBaseServer/KnowledgeBaseServer/KnowledgeServer/EditSnippet", sBody, true);
                }
                else
                {
                    sResponse = WebCommunications.SendPostRequest("http://dwlapi.azurewebsites.net/api/reflection/KnowledgeBaseServer/KnowledgeBaseServer/KnowledgeServer/AddSnippet", sBody, true);
                }

                this.Finish();
            };

            Button pDeleteButton = FindViewById <Button>(Resource.Id.btnDelete);

            pDeleteButton.Click += delegate
            {
                if (!m_bEditing)
                {
                    return;
                }

                // thanks to https://forums.xamarin.com/discussion/6096/how-show-confirmation-message-box-in-vs-2012
                var pBuilder = new AlertDialog.Builder(this);
                pBuilder.SetMessage("Are you sure you want to delete this snippet?");
                pBuilder.SetPositiveButton("Yes", (s, e) =>
                {
                    WebCommunications.SendGetRequest("http://dwlapi.azurewebsites.net/api/reflection/KnowledgeBaseServer/KnowledgeBaseServer/KnowledgeServer/DeleteSnippet?sfilename=" + m_sEditingSnippet, true);
                    this.Finish();
                });
                pBuilder.SetNegativeButton("No", (s, e) => { return; });
                pBuilder.Create().Show();
            };

            string sType = this.Intent.GetStringExtra("Type");

            if (sType == "new")
            {
                m_bEditing = false;
            }
            else if (sType == "edit")
            {
                string sSnippetName       = this.Intent.GetStringExtra("SnippetName");
                string sSnippetSourceName = this.Intent.GetStringExtra("SourceName");
                string sSnippetSourceText = this.Intent.GetStringExtra("SourceText");
                string sSnippetTags       = this.Intent.GetStringExtra("SnippetTags");

                m_bEditing        = true;
                m_sEditingSnippet = sSnippetName;

                // get the actual snippet content from the server
                string sSnippetContent = WebCommunications.SendGetRequest("http://dwlapi.azurewebsites.net/api/reflection/KnowledgeBaseServer/KnowledgeBaseServer/KnowledgeServer/GetSnippet?sfilename=" + sSnippetName, true);
                sSnippetContent = Master.CleanResponseForEditor(sSnippetContent);

                // remove the meta tags (since they are merely added back in on submit)
                Regex pRegex = new Regex(s_sMetaPattern);
                sSnippetContent = pRegex.Replace(sSnippetContent, "");

                // fill fields
                pSnippetContent.Text = sSnippetContent;
                pSourceData.Text     = sSnippetSourceText;
                m_pTags.Text         = sSnippetTags;
                m_pSources.Text      = sSnippetSourceName;

                this.Title = "Edit Snippet";
            }
        }