Delete SharePoint Page Programmatically

SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite("YOURSITE")) { using (SPWeb web = site.OpenWeb()) { //Obtain the page PublishingPageCollection publishingPages = PublishingWeb.GetPublishingWeb(web).GetPublishingPages(); PublishingPage page = publishingPages.FirstOrDefault(f => f.Uri.AbsoluteUri == "YOURPAGE"); if (page != null) { //Allow modifications bool webAllow = web.AllowUnsafeUpdates; web.AllowUnsafeUpdates = true; SPFile file = page.ListItem.File; //Delete file.Delete(); //Restablish default permissions web.AllowUnsafeUpdates = …

Sigue leyendo Delete SharePoint Page Programmatically

Disable input ENTER key in Chrome, FireFox, IE (including IE8), etc. by Javascript & JQuery

In order to disable the ENTER key in your textbox type input, you have to add the 'onkeydown' attribute and call a javascript function that checks the key and avoid to submit the form when you press ENTER key. Input example <input name="myName" type="text" value="Search" onclick="eraseInitialText(this);" onkeydown="disableEnter();"> Javascript function function disableEnter() { var key = …

Sigue leyendo Disable input ENTER key in Chrome, FireFox, IE (including IE8), etc. by Javascript & JQuery

Edit SharePoint Page By URL

If we couldn't acces to the menu item "Edit Page" for any reason and we want to edit that page (e.g. to remove some webpart that blocks our page) we've to add one parameter at the end: contents=1 Then, the URL would be like this: http://misyte.com/mysubsite/Pages/default.aspx?contents=1 By dong this we'll access to a standard SharePoint …

Sigue leyendo Edit SharePoint Page By URL

SharePoint 2013 + Visual Studio 2012: File «.g.cs» dissapeared

Sometimes, when you're developing a visual web part, the designer file (with .g.cs extension) dissapears in front of your eyes. After finding nothing in the internet, we've just discovered why it is happening: You've to add the "Site URL" property in the Project properties. That's beacuse it is a web part for sharepoint, and Visual …

Sigue leyendo SharePoint 2013 + Visual Studio 2012: File «.g.cs» dissapeared