.NET King Logo Comments on: Assigning master page to a SharePoint 2013 site programmatically (Client Side Object Model)
Skip Navigation Links
0 Items in Video cart!

Assigning master page to a SharePoint 2013 site programmatically (Client Side Object Model) (11/3/2015)

As I mentioned in the previous post, I put a simple function together to assign the master page for a SharePoint 2013 website using Client Side Object Model (CSOM). This function can be simply used in a provider hosted App or a simple consol application.


// Client Side Object Model
/// <summary>
This function gets the site Url and master page name and assigns the new master page to the site
<param name="siteUrl">The URL of the site you'd like to change the master page programmatically</param>
<param name="masterPageFileName">The file name of the new master page
void setMasterPageCSOM(string siteUrl, string masterPageFileName)
ClientContext ctx = new ClientContext(siteUrl);
Web rootWeb = ctx.Site.RootWeb;
List masterPageList = rootWeb.Lists.GetByTitle("Master Page Gallery");
File newMasterPage = masterPageList.RootFolder.Files.GetByUrl(masterPageFileName);
    ctx.Load(newMasterPage, mp => mp.ServerRelativeUrl);
Web currentWeb = ctx.Web;
    currentWeb.CustomMasterUrl = newMasterPage.ServerRelativeUrl;
    currentWeb.MasterUrl = newMasterPage.ServerRelativeUrl;

By: where to get cheap nfl jerseys  
In the WordPress support forum, there are from time to time questions abut trackbacks. I haven't used it myself, but I found a good tutorial on the OptiNiche cheap nfl jerseys china blog.
URL: http://www.alpha-montreal.com/cheapjerseys.asp  
By: cheap china jerseys nfl  
Pretty section of content. I just stumbled upon your web site and in accession capital to assert that I acquire in fact enjoyed account we supply cheap nfl jerseys your blog posts. Any way Il be subscribing to your augment and even I achievement you access consistently quickly.
URL: http://www.alpha-montreal.com/cheapjerseys.asp  
By: cheap nfl football jerseys for sale  
Il immediately postcheap nfl jerseys china snatch your rss feed as I can not find your email subscription link or newsletter service. Do you have any? Kindly allow me recognize so that I may subscribe. Thanks.
URL: http://www.alpha-montreal.com/cheapjerseys.asp  
By: 2rand[0,1,1]  
2Wd0cs https://goldentabs.com/
URL: 2rand[0,1,1]  
By: discount nfl jerseys china  
Since I didn't really understand how this works,we supply cheap nfl jerseys I did some searching and found an outstanding WordPress Trackback Tutorial that explains much of what I was finding confusing.
URL: http://www.alpha-montreal.com/cheapjerseys.asp  
By: FFXIV Gil  
How come you are working here?
URL: http://www.cheapguildwars2gold.net/ffxiv-some-other-fun-update-and-the-limitations-of-feature/  
By: Goheen  
reverse phone lookup in germany reverse phone lookup private number reverse phone lookup free no sign up
URL: http://reversephonelookup.bid  
By: buy nba 2k17 mt pc  
You are the savior of my life.
URL: http://forum.thb.vn/yaf_postsm17322_NBA-2K17-Patch-1-05-May-Arriving-Having-Pro-Am-Mend-And-Roster-Changes.aspx  
By: buy Cheap NBA 2K17 MT  
Do you have a good sense of humor .
URL: http://cylindrymiarowe.pl/blogs/25800  
By: Cheap NBA 2K17 MT XBOX ONE  
Why don't we give this a try?
URL: http://www.clubwww1.com/dating/member/blog_post_view.php?postId=58401  
By: Cheap NBA 2K17 MT Coins  
That makes two of us.
URL: http://nba2k17.mywapblog.com/sport-nba-2k17-should-have-cut-throat-eq.xhtml  
By: NBA 2K17 MT  
Today looks great .
URL: http://tmtctata.com/index.php/learning-resources/blogs/entry/nba-2k17-mycareer-badges-and-how-to-get-them.html  
By: nike air force mid  
I carry on listening to the reports lecture about getting free online grant applications so I have been looking around for the finest site to get one. Could you tell me please, where could i get some?
URL: http://www.eumill.it/victory.cfm?fg=id-6380  
By: nikita wikipedia  
I have been reading out many of your articles and it's nice stuff. I will make sure to bookmark your site.
URL: http://www.eumill.it/victory.cfm?fg=id-790  
By: nike free sverige  
My brother recommended I might like this website. He was entirely right. This post actually made my day. You cann't imagine just how much time I had spent for this info! Thanks!
URL: http://www.hammarsvens.se/class.asp?bw=id-5016  
By: nike tiempo legend iii  
I just couldn't leave your web site before suggesting that I really loved the standard information a person provide on your guests? Is going to be back often to check out new posts
URL: http://www.vecchiovarzi.it/test/plata.cfm?bw=nike-tiempo-legend-iii  
By: buy birkenstocks  
I truly appreciate this post. I have been looking all over for this! Thank goodness I found it on Bing. You've made my day! Thank you again
URL: http://www.euromode-eurosped.ie/yari.php?point=id-3635  
By: fifa 17 pc coins  
What is with that guy?
URL: http://www.kirchhertener-hunnen.de/index.php?forum-showposts-24999  
By: u4fifa.com  
i like this site a lot!
URL: http://forums.cozycot.com/forum/lifestyle/entertainment/4670753-fifa-17-address-problems-will-be-soon-fixed  
By: Albion Online Gold  
youre really talented.
URL: https://albiontips.wordpress.com/2016/07/06/six-laws-of-the-jungle-in-albion-pvp-world-%E2%85%A0/  
By: buy viagra  
Hello! I know this is kinda off topic but I was wondering if you knew where I could find a captcha plugin for my comment form? I'm using the same blog platform as yours and I'm having trouble finding one? Thanks a lot!
URL: http://ibuyallvehicles.com  
By: fifa coins  
Im very pleased with your work.
URL: http://patch.com/massachusetts/marthasvineyard/u4fifacom-professional-fifa-coins-seller-0  
By: nike air max 1 femme  
Hi there, after reading this amazing article i am too glad to share my knowledge here with friends.
URL: http://bioresp.eu/files/nike-air-max-1-femme.php  
By: nike air max kaufen  
I have been browsing online more than 3 hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. In my opinion, if all site owners and bloggers made good content as you did, the internet will be a lot more useful than ever before.
URL: http://hroniki34.com/templates/nike-air-max-kaufen.php  
By: oferta zapatillas salomon  
Hello, after reading this awesome paragraph i am too happy to share my familiarity here with friends.
URL: http://www.i-think.es/oferta-zapatillas-salomon.php  
By: christian louboutin outlet  
Definitely, what a magnificent site and enlightening posts, I surely will bookmark your site.Best Regards!
URL: http://www.colegiolamilagrosa.es/mail/christian-louboutin-outlet.asp  
By: buy blade & soul gold  
look great today.
URL: http://audiorealism.se/phpBB2/viewtopic.php?t=2684  
By: cheap adidas inc  
Thanks for some other fantastic post. The place else may just anyone get that type of info in such a perfect manner of writing? I have a presentation next week, and I am on the search for such info.
URL: http://www.meksyk-i-jego-zabytki.cba.pl/mains.php?adidas-1496.html  
By: �����å��� ��ȫѥ  
Well I definitely liked reading it. This post provided by you is very useful for good planning.
URL: http://www.rlvradio.com.ar/mains.php?asics-752.html  
By: �����å��� �ȥå�3  
Wonderful goods from you, man. I have understand your stuff previous to and you are just too great. I actually like what you've acquired here, certainly like what you're saying and the way in which you say it. You make it entertaining and you still care for to keep it sensible. I can't wait to read far more from you. This is actually a wonderful website.
URL: http://www.costaurbana.com.uy/mains.php?asics-381.html  
By: used mulberry bags Outlet  
This video post is actually enormous, the sound feature and the picture quality of this tape post is genuinely awesome.
URL: http://www.cruciblesnookerclub.com/uppe.cfm?no=id-7636  
By: mulberry stockholm rea  
I think this is among the most important information for me. And i'm glad reading your article. But wanna remark on some general things, The web site style is great, the articles is really excellent : D. Good job, cheers
URL: http://www.aloppe.se/onle.asp?hund=id-3266  
By: tommy hilfiger dunjacka dam  
What i don't realize is in fact how you're not actually a lot more well-preferred than you may be right now. You are very intelligent. You know therefore considerably when it comes to this subject, made me personally imagine it from numerous various angles. Its like men and women are not involved except it��s something to do with Lady gaga! Your personal stuffs outstanding. Always take care of it up!
URL: http://www.tekniskabyran.se/polaur.asp?rans=tommy-hilfiger-dunjacka-dam  
Your name: