net assgn

Upload: akash-saini

Post on 05-Apr-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 net assgn

    1/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 itto a master page 2. At the application level - By making a setting in the pages elementof the application's configuration file (Web.config), you can specify that all ASP.NETpages (.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 applyto 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 todynamically set:

    protectedvoidPage_PreInit(Object sender, EventArgs e)

    {

    this.MasterPageFile = "~/YourMaster.master";}

    http://roja-dotnet.blogspot.in/2012/03/how-do-you-apply-themes-to-entire.htmhttp://roja-dotnet.blogspot.in/2012/03/how-do-you-apply-themes-to-entire.htmhttp://roja-dotnet.blogspot.in/2012/03/how-do-you-apply-themes-to-entire.htm
  • 8/2/2019 net assgn

    2/3

    You can assign the master page dynamically with the help of Page class propertycalled MasterPageFile . You can assign this when the page is in PreInit stage. Below isthe 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)

    protectedvoid 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.

    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";

    }

  • 8/2/2019 net assgn

    3/3

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

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