Monday, 17 March 2014

Interview Q & A on CSS,Java Script and Master Page in Asp.Net(Part 2)

                                                                        CSS
1. Explain in brief about the term CSS.

A stylesheet language used to describe the presentation of a document written in a markup language.

2. What are the various style sheets?

Inline, external, imported and embedded are the different types of style sheets.

3. What are style sheet properties?

CSS Background
CSS Text
CSS Font
CSS Border
CSS Outline

4. List various font attributes used in style sheet.

font-style
font-variant
font-weight
font-size/line-height

5. What is the syntax to link external style sheet?

External style sheet are made up of css format only, it contains style information that can be linked with the HTML document externally. It is one of the easy and structured way as it keeps the style separate from the structure. It is a convenient way as only one file will be affected if any changes will be made overall. The file is linked through Link tag used inside the HTML Head. The syntax is as follows:
<HTML>
<HEAD>
<LINK REL=STYLESHEET HREF="style.css" TYPE="text/css">
</HEAD>
</HTML>

6. How embedded style can be linked with HTML documents?

Embedded style is inside the HTML code only. It is written using the <Style> tag and used under the <Head> structure. It gets applied to the element for which the style will be written. The syntax of it is as follows:
<HEAD>
<STYLE TYPE="text/css">
p {text-indent: 10pt;}
h1{text-color: #FFFFFF;}
</STYLE>
</HEAD>

7. How do I combine multiple sheets into one?

Multiple sheets can be combined into by using the <link> tag and the with the title attribute. The title value allows one or more <link> tags to link with each other. After combination that theme will be applied as combined and will be shown to the user. The syntax of it will be as follows:
<link rel= text/css href="default.css" title="combined">
<link rel= text/css href="style.css" title="combined">
<link rel= text/css href="para.css" title="combined">

Another way to combine the style sheets is the use of import which can be used in the <style> tag and the syntax can be given as follows:
@import url(site_url);

8. What are the rules in CSS ruleset?

CSS consists of two types of CSS rules, first is for ruleset which identifies the style and the selector. It combines the style and the selector. Ruleset is a combination of CSS rules, for example: h1{text-color: 15pt;}, where this is the CSS rule. Ruleset is selector + declaration for example: h1 + {text-color: 15pt;}

9. What is the CLASS selectors used for?

Class selectors are the selectors which are stand alone to a specific style that is declared. Class attribute can be used to declare the style and make an association with any HTML element. The syntax for creation of class selector is: .classname. The name can be from a-z, A-z or in digits. The example code is shown as below:

.head{font: 12em;}, this is a class selector
<Body class= head> this is the class that is associated with the element </body>.

10. What is the difference between class selector and ID selector?

Class selector can be given to an overall block. This is sometimes termed as block element as well, whereas ID selector identifies a unique name and a style for a specific element.
ID selector declares the style for only one particular element which can be differentiated from other element, whereas Class selector is being given for the whole complete block.
Example of ID selector is being written like this:
#idname {color: red; background: black;}
This can be used in HTML as

<P ID= idname>this element only will be affected by the use of this ID element</P> 

                                                          Java Script
11.JavaScript vs. Jscript?
Both JavaScript and Jscript are almost similar. Java script was developed by Netscape. Microsoft implemented its own scripting language and named it as Jscript.
12.What is the difference between Client side JavaScript and Server side JavaScript?
Client side java script comprises the basic language and predefined objects which are relevant to running java script in a browser. The client side java script is embedded directly by in the HTML pages.
13.How to Accessing Elements using javascript?
The elements of JavaScript are accessed by their names. By default the browser is accessed by the element ‘windows’ and the page by ‘document’. The corresponding element has user defined names for forms and its elements............
14.How to set the cursor to wait in JavaScript?
The cursor can set to wait in JavaScript by using the property ‘cursor’ property. The following example illustrates the usage.............
15.How do you assign object properties in JavaScript?
Java script object properties are assigned like assigning a value to a variable. For example, the title property of document object can be assigned as follows:
document.title="Welcome to the world of Javascripting";.
16.Is a javascript script faster than an ASP script?     
 JSP is faster then ASP as the script is run on the client side.
17.What is negative infinity?
Its a number that is obtained by dividing a negative number by zero. (in JSP).
18.What does isNaN function do?
The isNaN function determines if the value is a number or not and depending upon the result, it returns true or false.

19.What is the use of DOM?

DOM is also known as Document Object Model which is used to develop a model with documents or web pages containing objects like elements, links, etc. These objects can be manipulated or certain actions like add, delete or change of an element can be performed using this document object model. Through this change in attributes can be done to get all the list of all the elements in the document. The DOM model responds to API calls that result in documented level of DOM recommendation. It is used to support additional behavior on the web page and use of API give an extensible advantage over other models existing. DOM codes are reused to meet the requirement of the real world and to make all program interoperable.

20. Why JavaScript is called as Script for all browsers?

JavaScript is written after <SCRIPT> tag and it is surrounded in between the <!-- your code --> tags this is also known as comment tag. JavaScript interpreter treats the tag such that it treats all the lines in the comments as script lines. The JavaScript comment starts with // inside the <SCRIPT> tag. The script is contained inside <HTML> tag that contains a comment tag. The browser that is non-compatible with JavaScripts ignore the lines and move on, but compatible browsers always treats it as a script and execute it. The browser treat the written lines between the comment tag as normal lines and just thinking of the comment ignores it. Some browsers just treat the <!-- comment--> as a comment only and ignores whatever is written inside it.

21. Explain with an example the use of event handlers in JavaScript?

The events in JavaScript are the actions in a document that result from user activity. The actions are like clicking on a button or typing typing a character in the form. JavaScript object in a document that receives events of different kinds. To handle the events that are taking place requires an even handler that can handle the execution of the events. Event acts like an added attribute that is entered in object’s HTML. The attribute is consisting of event name, sign like (=), instructions. The following code shows the event handler as:
<HTML>
<BODY>
<FORM>
<INPUT TYPE=”button” VALUE=”Hello” onClick=”window.alert (‘HELLO WORLD’)”>
</FORM>
</BODY>
                                                                 Master Page

22.What is a Master Page?

ASP.NET master pages allow you to create a consistent layout for the pages in your application. A single master page defines the look and feel and standard behavior that you want for all of the pages (or a group of pages) in your application. You can then create individual content pages that contain the content you want to display. When users request the content pages, they merge with the master page to produce output that combines the layout of the master page with the content from the content page.

23.Can Master Pages be nested?

Yes, Master Pages be nested.

24.How do you bind a Content Page to a Master Page?

MasterPageFile attribute of a content page's @ Page directive is used to bind a Content Page to a Master Page.

25.Can the content page contain any other markup outside of the Content control?

No.

26.What are the advantages of using Master Pages?

1. They allow you to centralize the common functionality of your pages so that you can make updates in just one place.
2. They make it easy to create one set of controls and code and apply the results to a set of pages. For example, you can use controls on the master page to create a menu that applies to all pages.
3. They give you fine-grained control over the layout of the final page by allowing you to control how the placeholder controls are rendered.
4. They provide an object model that allows you to customize the master page from individual content pages.

27.What are the 3 levels at which content pages can be attached to Master Page?

At the page level - You can use a page directive in each content page to bind it to a master page

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.

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.

28.Can you dynaimically assign a Master Page?

Yes, you can assign a master page dynamically during the PreInit stage using the Page class MasterPageFile property as shown in the code sample below.

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


29.Can you access controls on the Master Page without using FindControl() method?

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

30.How does a content page differ from a master page?

A content page does not have complete HTML source code; whereas a master page has complete HTML source code inside its source file.

31.Difference between MasterPage and WebUserControl?

A master page is a template for other pages, which shares design and functionality with other pages. The master page provide a content place holder for other pages.

Web user control is a unit of functionality, which incorporate into parent page. it does not give a template design and functionality as master page gives. .NET provide .ascx extension for user control.



No comments:

Post a Comment