CHUVASH.eu

CHunky Universe of Vigourous Astonishing SHarepoint :)

webpart för att uppdatera title och description av web

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages"
    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WelcomeTextUserControl.ascx.cs"
    Inherits="MyProject.WelcomeTextUserControl" %>
<style type="text/css">
    #welcome-text-wp-input-title
    {
        font-size: 2em;
    }
    .welcome-text-wp-edit-mode, #welcome-text-wp-updateImage
    {
        display: none;
    }
</style>
<img src="/_layouts/Images/homepageSamplePhoto.jpg" alt="sample" class="teamsite-welcome-text-image">
<h1 id="welcome-text-wp-web-title" class="welcome-text-wp-show-mode">
    <%= SPContext.Current.Web.Title %></h1>
<p id="welcome-text-wp-web-description" class="welcome-text-wp-show-mode">
    <%= SPContext.Current.Web.Description %></p>
<img src="../_layouts/images/loading16.gif" id="welcome-text-wp-updateImage" />
<SharePoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControlUpdateWelcomeText"
    runat="server" Permissions="ManageLists">
    <div>
        <div>
            <input type="text" id="welcome-text-wp-input-title" value="<%= SPContext.Current.Web.Title %>"
                class="welcome-text-wp-edit-mode input" />
        </div>
        <textarea rows="5" cols="25" id="welcome-text-wp-input-description" class="welcome-text-wp-edit-mode input"><%= SPContext.Current.Web.Description %></textarea>
        <p id="welcome-text-wp-edit-button" class="welcome-text-wp-show-mode" onclick="javascript:toggleInputsVisibility();">
            edit</p>
    </div>
    <div>
        <input type="button" id="welcome-text-wp-input-submit" value="spara" class="welcome-text-wp-edit-mode button"
            disabled="disabled" />
        <input type="button" id="welcome-text-wp-input-cancel" value="avbryt" class="welcome-text-wp-edit-mode button" />
    </div>
    <script type="text/javascript">
        function updateWeb(webTitle, webDescription) {
            var ctx = new SP.ClientContext.get_current();
            this.web = ctx.get_web();
            web.set_title(webTitle);
            web.set_description(webDescription);
            this.web.update();
            toggleUpdateImageVisibility();
            ctx.executeQueryAsync(Function.createDelegate(this, this.onSuccessfulWebUpdate),
            Function.createDelegate(this, this.onFailedWebUpdate));
        }
        function onSuccessfulWebUpdate(sender, args) {
            var webTitle = jQuery("#welcome-text-wp-input-title").attr("value");
            var webDescription = jQuery("#welcome-text-wp-input-description").attr("value");
            jQuery("#welcome-text-wp-web-title").text(webTitle);
            jQuery("#welcome-text-wp-web-description").text(webDescription);
            toggleInputsVisibility();
            toggleUpdateImageVisibility();
            showWelcomeTextUpdateMessage("Välkomsttext uppdaterad")
        }
        function onFailedWebUpdate(sender, args) {
            resetValuesAndToggleInputsVisibility();
            toggleUpdateImageVisibility();
            showWelcomeTextUpdateError('failed to update title. Error:' + args.get_message())
        }
        function toggleInputsVisibility() {
            jQuery(".welcome-text-wp-show-mode, .welcome-text-wp-edit-mode").toggle();
        }
        function toggleUpdateImageVisibility() {
            jQuery("#welcome-text-wp-updateImage").toggle();
        }
        function resetValuesAndToggleInputsVisibility() {
            var webTitle = jQuery("#welcome-text-wp-web-title").text().trim();
            var webDescription = jQuery("#welcome-text-wp-web-description").text().trim();
            jQuery("#welcome-text-wp-input-title").attr("value", webTitle);
            jQuery("#welcome-text-wp-input-description").attr("value", webDescription);
            toggleInputsVisibility();
        }
        function showWelcomeTextUpdateError(errorMessage) {
            showWelcomeTextUpdateMessage(errorMessage);
        }
        function showWelcomeTextUpdateMessage(msg) {
            SP.UI.Notify.addNotification(msg, false)
        }
        jQuery(document).ready(function () {

            jQuery(".welcome-text-wp-edit-mode.input").live("keyup", function () {
                jQuery(".welcome-text-wp-edit-mode.button").removeAttr("disabled");
            });

            jQuery("#welcome-text-wp-input-submit").live("click", function () {
                var webTitle = jQuery("#welcome-text-wp-input-title").attr("value");
                var webDescription = jQuery("#welcome-text-wp-input-description").attr("value");
                updateWeb(webTitle, webDescription);
            });
            jQuery("#welcome-text-wp-input-cancel").live("click", function () {
                resetValuesAndToggleInputsVisibility();
            });
        });
    </script>
</SharePoint:SPSecurityTrimmedControl>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Вула Чăвашла

VulaCV - Чăвашла вулаттаракан сайт

Discovering SharePoint

And going crazy doing it

Bram de Jager - Coder, Speaker, Author

Office 365, SharePoint and Azure

SharePoint Dragons

Nikander & Margriet on SharePoint

Paul J. Swider - RealActivity

RealActivity is a specialized healthcare services and solution advisory firm.

Mai Omar Desouki - Avid SharePointer

Egyptian & Vodafoner - Senior SharePoint Consultant

Cameron Dwyer | Office 365, SharePoint, Outlook, OnePlace Solutions

Office 365, SharePoint, OnePlace Solutions & Life's Other Little Wonders

paul.tavares

Me and My doings!

Share SharePoint Points !

By Mohit Vashishtha

Jimmy Janlén "Den Scrummande Konsulten"

Erfarenheter, synpunkter och raljerande om Scrum från Jimmy Janlén

Aryan Nava

| Blockchain | Serverless Architecture | Microservices Architecture | DevOps | AWS Lambda | Teraform |

SPJoel

SharePoint for everyone

SharePointRyan

Ryan Dennis is a SharePoint Solution Architect with a passion for SharePoint and PowerShell

SharePoint 2020

The Vision for a Future of Clarity

Aharoni in Unicode

Treacle tarts for great justice

... And All That JS

JavaScript, Web Apps and SharePoint

blksthl

Mostly what I know about SharePoint - CommunicoCuspis

%d bloggers like this: