How to link Master page to other web pages - master-pages

I have a master page created on VisualStudio using C#. Just wondering when creating other web pages how do I apply the master page to it? Thanks

When you are adding the web pages - in the popup plese select the check box "Select Master Page"
Or Go to existing web pages directive and add the attribute masterpage and its file path change the path as like the below
<%# Page Title="" Language="C#" MasterPageFile="~/MainMasterPage.master" AutoEventWireup="true" CodeFile="Home.aspx.cs" Inherits="Home" %>

Related

Using WebMatrix and Razor

I am using WebMatrix to edit my web page. After clicking on the Run button, I can see the time being displayed, but when launching the page from the desktop I see the source code [#m_date.ToString()].
--snip--
#{var m_date = DateTime.Now; }
<!DOCTYPE html>
<head>
....
</head>
<body>
...
<p style="text-align: center">#m_date.ToString()</p>
...
</body
What am I doing wrong?
Thanks in advance.
Razor is a server-side technology. This means that your page needs to be processed by a server. This server turns the mix of html and razor code, into plain Html. This Html can then be rendered by your browser.
When you open a .cshtml directly in your browser, the razor code is not processed, and is displayed as the contents.
Webmatrix uses a server (IIS express most probably in your case) to launch your page. When you hit run it starts your browser and you go to url like localhost:12345 with the rendered (already processed) page.
If you have saved this page to your desktop it will be either html or cshtml depending on how you saved it. Then clicking on it does not process it, but rather you ask the browser to show the contents.
Here is an intro to Webmatrix to understand how it works and what it does when you do trivial things like this one.

Where do I go to enable search in Sharepoint 2007?

I am modifying an existing Sharepoint 2007 site. It just has two pages, the home page, and an admin page. The admin page has a couple form/document libraries. I simply want to have a search so that a user can search through all the documents/forms in the document/form library. I dont care if its a whole site search, as long as it pulls up results including those from all the document/form libraries on the site.
I have enabled site visibility ("allow this web to appear in search results") on both pages. I just cant find anywhere to enable an actual search button/search textbox/search webpart. I just want the actual control where i can type in a word and hit search. where/how can I enable that?
When I go to sharepoint designer I can see the search box at the top of the master page, but cant see it on the published (live) page.
First of all, search in MOSS 2007 is a BIG deal to understand... don't expect button "On/Off"!
Now that this is clear:
When you watch master page in sharepoint designer, you are seeing a page template as it would be seen with all functions enabled. So master page has to have the search button inside, so that MOSS knows where to show search button when it is enabled.
As for the first question:
First check in your server in the Central Administration Home page > if you have enabled search, crawling (to have any results in the first place) etc...
On your main site collection go to: "Site Actions > Site Settings > Modify All Site Settings > Site Collection Administration > Search settings" and check if you have enabled site search page.
Edit your search scopes.
P.S. Also I'm using a book for this kind of settings - great book
Office Sharepoint server 2007 - Administrator's companion
from Microsoft, written by Bill English (MS Sharepoint Community Expert)
Apparently a previous developer had modified the master page to hide the search feature controls.
The line in my master page that I had to edit was:
<td valign=top>
<asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server">
<SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox"/>
</asp:ContentPlaceHolder>
</td>
The table cell had an inline style to "display:none;" which I removed.

Difference between Master Page and MVC View Master page

Please check below screen shot. What is main difference between Master Page and MVC View Master page.
When I should use Master page and when I should use MVC View Master page.
Thanks.
alt text http://mahingupta.com/mahingupta/public/img/MsaterPage.png
The difference is the base class. In an ASP.NET MVC application you should use MVC View Master Page which derives from ViewMasterPage and you have access to helpers and it can be strongly typed to a model.

MOSS 2007: Changing the masterpage for one page layout

In a MOSS server, I would like a specific page layout to use the selected masterpage. Instead, i want this specific page layout to use a blank master page so i can use that page layout for pop message. I want to use a blank master page so that the my site's navigation menu, header and footer don't appear in my popup.
I found this blog post (Change MasterPageFile for a specific PageLayout) which explains how to do this but it requires the page to be ghosted which cannot be in my case.
Thanks
Create your own page layout in Sharepoint Designer, in the attributes of the page you can specify a masterpage url, instead of using the keywords ~default.master or ~custom.master use your own master page (make sure its published and available or it will fail).

Is it possible to share a masterpage between MVC and webforms?

I am adding MVC to a project that has MANY legacy webform pages. This works fine. However, I currently have a separate masterpage for MVC and for the webforms. The two master pages produce essentially identical output. I'd really like to kill the webforms one and just use the MVC master page with all my pages and stay DRY.
Not being DRY has already bitten me a couple times when I forgot to change both.
I tried doing the obvious way and just pointing the webform content page's MasterPage attribute at the MVC masterpage. This throws an error saying the MVC masters only work with MVC views.
This seems like it would be a pretty common problem with mixed MVC and webform projects. My MVC master isn't doing anything with ViewData, so I don't see any reason the webforms couldn't use them.
You can absolutely share the same master page. Your MVC master page must simply point to the WebForms masterpage via its MasterPageFile attribute. This applies your WebForms MasterPage styles to your MVC MasterPage.
I am using this setup in production.
The declaration on my MVC Master Page, pointing at the Web Forms Master Page:
<%# Master Language="C#" MasterPageFile="~/MasterPage/Site.Master"
AutoEventWireup="true" Inherits="System.Web.Mvc.ViewMasterPage" %>
Works like a charm.
This blog post walks you through the necessary steps to share WebForm and MVC master pages with little or no duplication. It also includes a sample project you can download, and I found it quite helpful.
One hiccup I ran into was that I was using a LoginStatus control in my header. LoginStatus must be inside a form so I couldn't use it in my root master page (not wanting to end up with nested forms on all my MVC pages). But that was a pretty easy control to replace with a simple code block in my root master page.
In my webforms app, my master page inherits from "HLPUSD.SMART.SMARTMaster" which is just the namespace for our application and then the name of the webform class.
In my MVC project, the master page inherits from "System.Web.Mvc.ViewMasterPage"
Me thinks this has something to do with it?

Resources