Sharepoint 2016 - One master page for every site - c#

I am currently working on a SharePoint 2016 system. We are upgrading from a SharePoint 2010 where we had one master page. Our goal is to have a single master page for every site in our environment. We can't use publishing to do this since we need site templates. So that route is out.
If possible I am looking for a way to catch, perhaps via a feature, when the masterpage is loading and redirect it to use custom master page. I haven't been able to find an event that I can use to do this.
Note: This is an onsite installation and not office 365.
Any help would be much appreciated.

After a long while we finally settled on a solution. We created two features. One for the site collection and one for SharePoint Central Administration.
The site collection feature forces all children sites to update their master page to a specific one. It also adds event listeners for new sites so that they also point to the correct master page.
The web app feature is used as a "switch". When it gets enabled it activates the site collection feature. When it gets disabled then it deactivates the site collection feature.
It's not a super great solution. However I thought I might post it here for those that are unable to move away from SharePoint (like us).

Related

In a ASP.NET Webforms App - The purpose of Site.Mobile.Master and the ViewSwitcher.ascx control

I normally delete ViewSwitcher.ascx and Site.Mobile.Master from my project whenever I create a new WebApp using the default Webforms template.
After researching I believe the Site.Mobile.Master and ViewSwitcher.ascx are used along with the new Friendly Urls feature.
I am looking for some information on why Microsoft added these files to the default webforms template and how/when I would go about using them. I usually create web applications that run on both desktop and mobile using the same master page.
It seems like a scenario when I would want to use Site.Mobile.Master is when I want to completely separate mobile from desktop. Meaning I would have 2 files like this:
AboutUsMobile.aspx (uses Site.Mobile.Master)
AboutUs.aspx (uses Site.Master)
I believe the ViewSwitcher control simply allows the user to leave mobile and switch to the desktop page.
However, I do not understand what logic is in place to automatically take the user to the Mobile page vs the Desktop page.
I just feel like I don't see the full potential in using these controls and how they work with the new URL routing. Any information on these items would be great.

After building and running asp.net website my page get refreshed automatically one time

I am new to asp.net
I have created a small web site in visual studio 2010 using asp.net and C#.
whenever i run the website it get refreshed one time automatically.
I have not used any meta tag refresh attribute.
why this happening, Please help.....
Sounds like a browser issue rather than a code one. Try checking your browser extensions and settings, something may be conflicting with the default.aspx page. Try pressing F12 as well and check the console. It will tell you if something is going wrong.

Adding a re-usable 'box' to my asp.net web app

I'm building a basic web application in ASP.NET 4.0 with C# in Visual Studio 2010 Pro. I'm still very new to C#, and am used to Delphi coding. My website already has registration/login, and although I use some asp.net controls, a majority of my pages are dynamically loaded from my SQL database and I manually compile the HTML code from C# and insert it into the document.
Now what I would like to do is implement a poll - or a vote box - an 'object' which can be re-used in different pages. My website's master page already has a permanent left panel which has things which show on every page. One of these will be a small box with a vote of a few questions.
All I need to know is how do I begin to build an independent plugin control for a web page like this? I don't necessarily mean a separate DLL or anything, my existing one can handle everything. But I'd like to re-use the same little voting box in different pages too. So I'm assuming this will be considered a separate page, in a way, which is probably about 120 pixels wide by 80 high. Each vote will be limited to either login account or ip address (which I already have access to). So this solution must interact with the existing asp.net application.
So how do I begin the 'backbone' of such a plugin which can be re-used in multiple pages? I do not plan on distributing this plugin, and I don't even know if this is the correct term for what I need. Just a 'box' which can be 're-used' on multiple pages - which must interact with the asp.net app.
To better explain what I mean, imagine how Facebook has the plugin where you can embed some general info about likes and such. I'd like to make my own box like this - and even be able to embed it in other websites.
It sounds like you just need to make the poll into a user control. The documentation should get you started with them. A control can access everything an ASP.NET page can when it comes to the login information. It won't handle embedding into other pages though – embeddable active content that authenticates against your site is a nontrivial problem.
As I said in the comment, if most of your HTML is creates as a blob that's opaque to ASP.NET, it will probably be nontrivial to insert a user control into the middle of it.

How to show the list of recently visited web pages as chrome does

I would like to display the list of recently accessed/visited web pages just as google chrome shows. I want to achieve this using C# and asp.net.
I am working on a site where the user can see the list of pages that they have visited, I tried using iframe but that does not work as per expectation. I am looking for a clean and intuitive interface something like google chrome.
I would like to provide a thumbnail view of the recently visited pages.
To keep my question simple, I want to display a list of urls as thumbnails, just as chrome does
Note that Chrome can do it easy, as they get to render the page and can take a bitmap snapshot of it easily to show for the thumbnails. (These are not live websites in there)
If you want to do the same thing, you have to render the website offscreen and take a snapshot to show to the user.
If you want to actually show a live website - now that's another story. There are a lot of sites that don't like being shown in the context of another website (for whatever reasons - security, marketing and so on) and will employ any tricks (including legal) to make sure this does not happen.
Pages only visited within your own app?
There are several components that will alow for that using their api. For example:
http://www.tonec.com/products/wssh/index.html
You can just take a snapshot after the DOM for tha page is completely generated and save the output using the tool on peruser basis.
Now, if you want something more generic that works for any web site, you'd probably want to go with a web browser plugin.
Here would be a possible solution, although I've not tried it personally:
Keep a record of all the pages that a user visits (e.g. in a database)
When the user visits a landing page on your site, you could call the WebBrowser.DrawToBitmap function to render a bitmap of each page they have visited recently.
Please note: this is just a theory, I'm not saying it will work! ;)
This link might help you get started:
http://pietschsoft.com/post/2008/07/c-generate-webpage-thumbmail-screenshot-image.aspx

Prompting a user when activating a SharePoint feature through the site

I would like to know if there is a way to prompt the user when activating/deactivating a feature within SharePoint.
The background behind this is that I have a SharePoint solution that deploys several configuration files that are modified by the user when deployed to the site. I would like to either allow the user to decide whether or not to overwrite the files when activating or deactivating a feature.
Thanks guys!
Do you need this to work on ANY feature that is activated in your site, or just on features that are developed by you? If this is the latter case, you can add an event handler (SPFeatureReceiver) to your feature and catch the feature activated event.
EDIT: As per #Muhimbi's comment I finally understood the question - you want to allow user edit some properties and only then to activate the feature. In this case, I would suggest to define the feature as "hidden", so it does not show up in "web features" and "site features" list. Then create a custom page for "administration" of this feature, which would allow the user to override the settings in question etc. Then, register this administration page with SharePoint (again, deployed as a feature, these two features may be stapled together). Quote a good article about it can be found here: http://www.tonstegeman.com/Blog/Lists/Posts/Post.aspx?ID=13
EDIT2: found a similar article here on SO: SharePoint Feature Activation Form
One of the responses gives a good point - "The problem is, you don't always know where your feature activation code is going to run. If you turn on the feature using stsadm, it will execute in stsadm.exe, not the web process."

Categories