.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

Can a page inheriting from masterpage have its own CSS?

Posted By:      Posted Date: September 23, 2010    Points: 0   Category :ASP.Net

Hi all I was wondering if it was possible to add CSS styles to a content page? I am trying to add styles to one of my content page by using a <link rel> tag but I get a compilation error. Is there another way of doing this?

I was thinking of loading all my styles on the MasterPage and then just using them as I need to but surely thats an inefficient way of doing things? I want to be able to just include CSS files that are relevant to the single content page...

Thanks in advance, Onam.

View Complete Post

More Related Resource Links

Sharepoint 2007 - Wiki site - New Pages Not Inheriting Custom Master Page


I am working on a SP site (MOSS not WSS) which is heavily customised away from the OOTB layout. I need to create a Wiki site, which was going well - I've created a master page which displays the miniconsole (this was not visible with our customised layout), and made it the default master page for the site. This has been applied to the two standard pages that come with the Wiki site, however when a new page is created, it seems to inherit the default.master, rather than my custom master page - thus not showing the miniconsole.

When I have created a new page, I am able to use SharePoint Designer to attach my custom master page to it, which works perfectly, however this will not be a viable option going forward as end-users create their new wiki pages.

How can I get the new pages to inherit my master page when they are created?


Masterpage didnt get applied to a particular _Layouts files(application page) for EditUserPref.asp

Master page did nt  get applied to a application page  (_layout file),   but other layout pages have the master page applied. EditUserPref.aspx  ->  Im accessing from search preference - http://i34.tinypic.com/34xi9t5.jpg  

classic asp pages as the masterPage of an asp.net 2.0 page

hiya folks,I'm upgrading a classic asp app that contains include files as a kind of masterPage, eg  topMenu.asp etc.I want to plug and aspx child page into the app with as little alteration as possible...Simply including the asp pages in the aspx page doesn't work, as asp.net 2.0 obviously tries to "handle" the classic asp page, and it errors.<<CS1010: Newline in constant>>  .. i believe because c# is trying to interpret the VB server side code.So, how can I plug the classic asp stuff in as easily as possible?many thanks,yogi

How to associate custom masterpage from 12 hive folder to an ASPX page

scenario: I have a custom masterpage available within 12 hive folder.  I want one of the ASPX pages (say allitems.aspx) to use this masterpage. I see that when I open the ASPX page using SPD, it has default.master but upon changing it to mydefault.master it gives error indicating that file is not found. So question is how to reference custom masterpage in aspx pages? I prefer to do it through visual studio but SPD is also fine.   thanks.

where i should put jscript code in aspx page, which created by inheriting a master page


hi budies,

 i am creating a simple web portal, but i am stuck in a aspx page which created by inheriting master page ,

there is some jscript code, but i don't know where to put this code in that page.

please help out ppls. 

thanx in advance 

Masterpage not inheriting



I am using Sharepoint 2010 Enterprise, i have created a site collection and have used a Publishing Site as the template for the portal.  I have customised the master page of the site and everything looks good.  When i add a subsite, although the masterpage settings are set to inherit the parents masterpage, this is not happening.  Instead the subsite is using its own masterpage and i need to make my changes all over again to this site. 

How can i make it so that the site will inherit the master page of its parent? am i doing something wrong?

On the subsite, under http://spoint2010/Departments/_Layouts/ChangeSiteMasterPage.aspx all 3 options for Site Master Page, System Master Page and Alternate CSS URL are set to Inherit site master page from parent of this site.

Same aspx page with 2 different masterpage: is it possible??

Hi All,

I'm trying to solve the following issue:

I need that the same page (stored in a document library) can be accessible from two diffenet website... (let's call it page.aspx)

we can say web1 and web2

I have also created 2 masterpages: master1 and master2

I need to achieve the following scenario:

if I open "page.aspx" from web1, it should load up the masterpage master1

if I open "page.aspx" from web2, it should load up the masterpage master2

is it possibel to achieve this in sharepoint???

I'm just downloading Visual Studio 2010 to try so play around with this, because with sharepoint designer I cannot find anything usefull...

any suggestion to make this "strange" process work????

this is due to have the same content in just one repository (so if I have to change something I do it once) and present the information with two different layouts...

thanks all


Custom template not inheriting custom masterpage/branding


We are in the process of migrating from MOSS 2007 to Sharepoint 2010 nad need to recreate site templates used in multiple business processes. We have done the Visual upgrade and designed a new Master Page/CSS that is compatible with 2010. However - To create a template, Publishing must be off. But when I create a site from these templates, they do not inherit the custom master page because Publishing is not enabled.

So to this point  it appears I cannot create a template that will inherit my branding. Is that the case? 

Pulling value from masterpage textbox into content page


Hi Guys,


As the topic suggests, I am having a slight issue with grabbing data from my masterpage into my content page (as a whole).


I have generated a public property for the my textbox and the contentpage can see this public property. But it comes across empty (even from within the masterpage). Now I guess the problem is with the property itself (possibly). It also shows as empty when I response.write it's value to the page.


Even when I call the value of the property in the masterpage it comes across as empty. The way I have this setup is that a textbox named pageTitleField has it's value updated from an iframe. All is working well and the textbox has its value updated correct upon iframe content changes. This is great. Now I just need to pass this textbox value into my content page and then set it as the document title.


Please see my code thus far.


My MasterPage

<%@ Master Language="VB" CodeFile="site.master.vb" Inherits="site" AutoEventWireup="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat

Shared class on masterpage and normal page.



NewBie question :

I've created a nice menu class and used it in my MasterPage like "using My.GeneralRoutines".

This class is working well and everything is fine UNTIL I want to access this same instance of that class that was created at MasterPage level on "a_page.aspx.cs" (this page is using the MasterPage like :)

<%@ Page Title="" Language="C#" MasterPageFile="~/Templates/My.Master" ...

I've got no pointer to the MasterPage My.GeneralRoutines.Menu class. Can someone give me a hint on this one ?

My eventual goal is to set a property of the menu class as CurrentMenu on "page.aspx.cs" level, so that the class on the masterpage (the same one .. if so ..) knows what to display.

Kind regards

Global Nav on Custom Masterpage not Inheriting Settings



I currently have a Publishing site with workflow and multiple subsites that are also publishing sites. The global nav on the subsites needs NOT to inherit the links from the parent site. The system pages are reflecting these settings correctly, but the pages with the custom master attached are not... They all show the same navigation as the parent site, regardless of any changes to the navigation settings.

I have carefully checked the global nav control for the custom master, and it is identical to the global nav in the v-4 master. I've also tried removing custom styles as a last resort and have not found a reason in the custom master, for this problem to be occurring.

Has anyone experienced this issue before and found a solution?

Any help would be much appreciated!

Rebecca Zimmerman

Inheriting from publishing page content type does not allow for overriding fields in SharePoint 2010


Hi there, we are creating custom content types that inherit from the "Page" content type.  We have found that we must have the "Inherits" property set to "TRUE" or else our custom content types do not show up in the content type gallery.  If we query the site collection using management shell the content type does appear to be there, but unfortunately it will not publish from the content type hub. If we set Interits=TRUE the content type deploys properly and appears in the content type gallery, but we cannot override (change the display name) or remove any of the inherited fields. Ultimately, we would like to have our content types inherit from "Page" and also override some of the "Page" fields, but this does not appear to be possible. We have spent quite a bit of time on this issue and are wondering if this is a bug or intential behavior of the "Page" content type. Any information you can provide would be appreciated? 

P.S. We have ran similar tests inheriting from "Document" and "Item" content types and do not encounter the same issue with overriding inherited fields.


Changing the graphics on the home page of a SharePoint site

When you create a site in Microsoft Windows SharePoint Services by using the default Team Site template, the home page includes two default graphics. A Windows SharePoint Services graphic appears in the body of the page, and a picture of a house in a circle appears near the site title. You can change these graphics to customize your site. Changing the smaller graphic requires a Windows SharePoint Services compatible Web page editor

Using jQuery to directly call ASP.NET AJAX page methods

Here I am looking to explain how to call page methods using jQuery. Using jQuery to directly call ASP.NET AJAX page methods

Reduce ASP.NET Page size and complexity using JQuery

This is my first post on asp.net blog. ASP.NET Ajax and JQuery are two different ajax framework. In this post I will show, how we can enhance gridview using ASP.NET Ajax and JQuery. I also compare the implementation of these frameworks. In next posts i will explain more about JQuery and ASP.NET Ajax and also tell you "How to combine the power of both framework". My Future post will related to ASP.NET and related frameworks.


I have 2 web pages. First page has a textbox and a button control.

when I enter test and click on the button , system goes to the second page. And in the second page I want to access the Textbox in the first page. When I try to do this I get the following error.

"Object reference not set to an instance of an object. Following is my code :

Dim txt As New TextBox

' Find the server name on the previous page
txt = CType(Page.PreviousPage.FindControl("TextBox2"), TextBox)
If Not IsNothing(txt) Then
Response.Write("[Name Not available]")
End If

I know I could do this with session, but I want to use the Page.PreviousPage.FindControl. Any help is greatly appreciated

Unique content within master page based on conditions met


 Hi all-

I would like to present users with unique content based on certain conditions being met as they land on the home page (default.aspx).  The condition logic will be in the VB code behind Page Load event. The content will go in a content placeholder as specificed from the master page. 

However, the content change wouldn't be something small (ie making a panel or label visible or not) but rather it will be different HTML,  Divs and databound gridview content.  The HTML content will be stored in the database.

Can someone point me in the right direction for best practices on how to accomplish this?


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend