locked
The name 'cmdUpdate' does not exist in the current context RRS feed

  • Question

  • hi Guys,

    I am trying to deploy a masterpage application page into my site collection but i keep getting the error message 'The name 'cmdUpdate' does not exist in the current context'. Thanks!  

    using System;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.WebControls;
    using Microsoft.SharePoint.Utilities;


    namespace MasterPageDemo.Layouts.MasterPageDemo
    {
        public partial class MasterPageManager : LayoutsPageBase
        {
            protected override void OnInit(EventArgs e)
            {
                base.OnInit(e);
                cmdUpdate.Click += new EventHandler(cmdUpdate_Click);
            }
            void cmdUpdate_Click(object sender, EventArgs e)
            {
                SPWeb site = this.Web;
                string WebAppRelativePath = this.Web.ServerRelativeUrl;
                if (!WebAppRelativePath.EndsWith(@"/"))
                {
                    WebAppRelativePath += @"/";
                }

                string currentMasterPage = site.MasterUrl;
                if ((radDefaultMaster.Checked) && !currentMasterPage.EndsWith("defualt.master"))
                {
                    site.UIVersion = 3;
                    site.UIVersionConfigurationEnabled = true;
                    site.Update();
                }

                else if ((radv4Master.Checked) && !currentMasterPage.EndsWith("v4.master"))
                {
                    site.MasterUrl = WebAppRelativePath + "_catalogs/masterpage/v4.master";
                    site.UIVersion = 4;
                    site.UIVersionConfigurationEnabled = false;
                    site.Update();

                }

                else if ((radSampleMaster.Checked) && !currentMasterPage.EndsWith("Sample.master"))
                {
                    site.MasterUrl = WebAppRelativePath + "_catalogs/masterpage/Sample.master";
                    site.UIVersion = 4;
                    site.UIVersionConfigurationEnabled = false;
                    site.Update();

                }

                SPUtility.Redirect("settings.aspx", SPRedirectFlags.RelativeToLayoutsPage, this.Context);
            }
        }
    }


    • Edited by Aiman_10 Wednesday, March 6, 2013 8:43 PM
    Wednesday, March 6, 2013 8:34 PM

Answers

  • I think you'll have to recreate the file then and move the existing code to the new file

    SharePoint Developer | @zeemanj | Blog

    Thursday, March 7, 2013 8:23 PM

All replies

  • Is the cmdUpdate also generated in the designer file? I assume that the project builds fine and this is a runtime exception?


    SharePoint Developer | @zeemanj | Blog

    Wednesday, March 6, 2013 9:23 PM
  • Thanks Jeffrey!

    Its not generated there and i was hoping to delete the designer file and recreate it by using the option conver to web application but i could not find that option by right clicking the cs file. I am using VS 2010 Professional.

    I have no idea what to do next!

    Thanks!

    Wednesday, March 6, 2013 9:58 PM
  • You can try the following

    • Clean the designer file and delete everything in the file, leaving it blank and save
    • Select everything in the ASPX/ASCX file and cut everything and then re-paste it back
    • The designer file should have regenerated the code


    SharePoint Developer | @zeemanj | Blog


    Thursday, March 7, 2013 6:49 PM
  • Thanks, i did the above stated steps but could not regenarte the code.
    • Edited by Aiman_10 Thursday, March 7, 2013 8:01 PM
    Thursday, March 7, 2013 8:00 PM
  • I think you'll have to recreate the file then and move the existing code to the new file

    SharePoint Developer | @zeemanj | Blog

    Thursday, March 7, 2013 8:23 PM
  • Ok, thanks for the help!
    Thursday, March 7, 2013 9:18 PM