CHUVASH.eu

CHunky Universe of Vigourous Astonishing SHarepoint :)

Tag Archives: application page

PeopleEditor med ifyllt värde

I vissa fall är det bra att ha ett ifyllt värde i PeoplePicker, till exempel, namn på personen som kör koden. Det finns olika beskrivningar om hur man gör det. Allmänt, och mer specifikt för webparts. Jag har även testat kod från boken Sharepoint 2010 as a Development Platform:

private PeopleEditor peopleEditor;
private void EnsureChildControls()
{
  peopleEditor = new PeopleEditor();
  peopleEditor.AutoPostBack = true;
  peopleEditor.ID = "MyPeopleEditor";
  peopleEditor.AllowEmpty = false;
  peopleEditor.MultiSelect = true;
  peopleEditor.SelectionSet = "User,SPGroup" ;
  MyPanel.Controls.Add(peopleEditor);
}
protected void initPeopleEditor()
{
  PickerEntity entity = new PickerEntity();
  entity.Key = SPContext.Current.Web.CurrentUser.LoginName;
  // Make sure the entity is correct
  entity = peopleEditor.ValidateEntity(entity);
  ArrayList entityArrayList = new ArrayList();
  entityArrayList.Add(entity);
  peopleEditor.UpdateEntities(entityArrayList);
}

Problemet med denna kod är att man får felet “Ingen exakt matchning” och man kan inte submitta.

I application pages kan man enkelt fylla i aktuella användaren genom att ändra CommaSeparatedAccounts property i Page_Load-metoden.

peopleEditor.CommaSeparatedAccounts = SPContext.Current.Web.CurrentUser.LoginName;

Att skriva direkt i aspx-sidan funkar tyvärr inte:

<SharePoint:PeopleEditor
	ID="siteOwners"
	runat="server"
	ValidatorEnabled="true"
	AllowEmpty="false"
	MultiSelect="false"
	SelectionSet="User"
	CommaSeparatedAccounts="<%# SPContext.Current.Web.CurrentUser.LoginName %>"
	/>

masterpage i application page

Om det inte funkar att ändra masterpage genom DynamicMasterPageFile:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CreateNews.aspx.cs" Inherits="MyProject.Layouts.MyProject.CreateNews"
    DynamicMasterPageFile="~masterurl/default.master" %>

Kör det här

 <script type="text/C#" runat="server">

    protected override void OnPreInit(EventArgs e)
    {
        base.OnPreInit(e);

        this.MasterPageFile = "/_catalogs/masterpage/my-custom.master";
    }

</script>
Вула Чăвашла

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

Discovering SharePoint

And going crazy doing it

Bram de Jager - Architect, Speaker, Author

Microsoft 365, SharePoint and Azure

SharePoint Dragons

Nikander & Margriet on SharePoint

Cameron Dwyer

Office 365, SharePoint, Azure, 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

DevOps, Cloud and Blockchain Consultant

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

SharePointDiver

SharePoint på ren svenska