You are on page 1of 3

Ques2.a)What is the difference between themes and CSS?

Sol-a)
In case of CSS you can define only style properties but a theme can define multiple properties of a control not just style properties such as you can specify the graphics property for a control, template layout of a GridView control etc. The CSS supports cascading but themes does not support. The CSS cannot override the property values defined for a control but any property values defined in a theme, the theme property overrides the property values declaratively set on a control, unless you explicitly apply by using the StyleSheetTheme property. You can apply multiple style sheets to a single page but you cannot apply multiple themes to a single page. Only one theme you can apply for a single page.
CSS usually deals with HTML code. You cannot apply CSS to certain ASP.NET specific server controls which are not present in HTML. You can apply Themes and skins to all ASP.NET controls with less effort. Themes and skins can be uniformly applied on both windows and asp.net applications. You can apply single theme to each page where as multiple style sheets can be applied to each page. Themes dont override or cascade style definitions by default the way CSS generally do. But you can selectively override local property settings for a control using StyleSheetTime attribute in Themes. You can include CSS files in Themes which is applied as part of Theme structure but not vice-versa. You can apply theming for only those properties that have ThemeableAttribute attribute set to true in their control class

Ques-b)How do you apply Themes to an entire application?

http://roja-dotnet.blogspot.in/2012/03/how-do-you-apply-themes-to-entire.htm

Ques3-a) What are the three levels at which content pages can be attached to Master

Page? Sol-a) 1. At the page level - You can use a page directive in each content page to bind it
to a master page 2. At the application level - By making a setting in the pages element of the application's configuration file (Web.config), you can specify that all ASP.NET pages (.aspx files) in the application automatically bind to a master page. 3. At the folder level - This strategy is like binding at the application level, except that you make the setting in a Web.config file in one folder only. The master-page bindings then apply to the ASP.NET pages in that folder.

Ques4-a)Can you dynamically assign a Master Page? Sol-a) Assign the master page in PreInit of the page whos MasterPage you wish to
dynamically set: protected void Page_PreInit(Object sender, EventArgs e) { this.MasterPageFile = "~/YourMaster.master"; }

You can assign the master page dynamically with the help of Page class property called MasterPageFile . You can assign this when the page is in PreInit stage. Below is the sample code to assing master page dynamically.

void Page_PreInit(Object sender, EventArgs e) { this.MasterPageFile = "~/MasterPage.master"; }

Yes. Set the MasterPageFile property only during the PreInit page eventthat is, before the runtime begins working on the request (since the rendering of the page with the master page occurs prior to the Init event) protected void Page_PreInit(object sender, EventArgs e) { MasterPageFile = "simple2.master"; } If you try to set the MasterPageFile property in Init or Load event handlers, an exception is raised. Note: The Master property represents the current instance of the master page object, is a read-only property, and can't be set programmatically. The Master property is set by the runtime after loading the content of the file referenced by the MasterPageFile property. The above code needs to add in every page of the site. Instead, it is easy enough to add that code to a base page class that you can inherit from for you pages in the site. In case if you do not already have the base page, you can use the following web.config settings to have a base class without having to modify the existing aspx pages. <system.web> <!-- ... --> <pages pageBaseType="MyWeb.UI.MyPageBase" /> <!-- ... --> </system.web>

4-b) Can you access controls on the Master Page without using FindControl() method? Sol-b) Yes, by casting the Master to your MasterPage as shown in the below code
sample. protected void Page_Load(object sender, EventArgs e) { MyMasterPage MMP = this.Master; MMP.MyTextBox.Text = "Text Box Found"; }

http://dotnet4u-me.blogspot.in/

You might also like