ASP.NET HTML and Web Server Control - Placement questions

ASP.NET HTML and Web Server Control - Placement questions


Q.1 Which is the first event of ASP.NET page, when user requests a web page?

A) PreLoad
B) Load
C) Preinit
D) Init
View Answer / Hide Answer

ANSWER: C

Explanation:

1) PreInit: This event is also useful when you are dynamically (from code) set values such as master page, theme or dynamically created controls for a page.
2) Init: This event fires after each control has been initialized.
3) InitComplete: This event fires all initializations of the page and its controls have been completed.
4) PreLoad: Executes before view state has been loaded for the page and its controls and before PostBack processing.
5) Load: This event checks for PostBack and then sets control properties.
6) Control (PostBack) event(s): This event fires when any events on the page or its controls that caused the PostBack to occur. For example button’s click event.
7) LoadComplete: At this point all controls are loaded.
8) PreRender: This event fires after all regular PostBack event have taken place. It is executed before saving ViewState.
9) SaveStateComplete: If anyone makes changes to the page’s controls at this point or beyond, they are ignored.
10) Render: This event generates the client-side HTML, DHTML, and script that are necessary to display a control at the browser.
11) UnLoad: This event is used for cleanup code.




Q.2 If a user wants to create controls at runtime which event should be used to write code?

A) PreLoad
B) Load
C) Init
D) PreInit
View Answer / Hide Answer

ANSWER: D

Explanation:

Use of PreInit Event.

1. Create controls dynamic.
2. Set a master page dynamically.
3. Set the Theme property dynamically.
4. Read or set profile property values.




Q.3 What is the fully qualified name of the base class of all server controls?

A) System.Web.UI.Control
B) System.Web.UI
C) System.Control
D) All of the above.
View Answer / Hide Answer

ANSWER: A

Explanation:

System.Web.Ul.Control is the base class for all the web server control like ASP.NET




Q.4 When should you use HTML server control rather than web server controls?

A) You are migrating existing, classic ASP pages over to ASP.NET pages.
B) The control needs to have custom client-side JavaScript attached to the control’s events.
C) The Web page has lots of client-side JavaScript that is referencing the control.
D) All of the above.
View Answer / Hide Answer

ANSWER: D




Q.5 Which attribute is necessary for HTML control to work as a HTML server control?

A) runat=”server”
B) runat=”web-server”
C) ID=”server”
D) ID=”web-server”
View Answer / Hide Answer

ANSWER: A

Explanation:

The HTML server controls are HTML elements that include a runat=”server” attribute. HTML server controls provide automatic state management and server-side events. The runat=”server” attribute is necessary for HTML control to work as a HTML server control.




Q.6 How will you add a TextBox control at runtime on the form? Choose the correct one.

A) TextBox obj = new TextBox();
obj.ID = "txtUserName";
form1.Controls.Add(obj);

B) form1.Controls.Add(TextBox);

C) this.FindControl.add(TextBox);

D) None of the above.
View Answer / Hide Answer

ANSWER: A

Explanation:

TextBox is a predefined class in ASP.NET. If you want to create TextBox control at runtime you have to create the object of TextBoxt class. Here obj is the instance of TextBox class. Then create the ID of the textbox control. At last add this control by using Add method.




Q.7 Some control, by default, does not cause an automatic PostBack, i.e TextChanged event of TextBox. Which property will you set for automatic postback of these types of controls?

A) isPostBack=”false”
B) isPostBack=”true”
C) PostBack=”true”
D) AutoPostBack=”true”
View Answer / Hide Answer

ANSWER: D

Explanation:

Some controls in ASP.NET, the AutoPostBack property is false by default, i.e TextBox, RadioButton, CheckBox control etc. For automatic postback of these control’s default event you have to set AutoPostBack property to true.




Q.8 What property do you modify on a server control to minimize the size of the ViewState data?

A) ViewState=”true”
B) Set EnableViewState to false.
C) Set EnableViewState to true.
D) None of the above
View Answer / Hide Answer

ANSWER: B

Explanation:

In ASP.NET when a form is postback to server it reappears in the browser with all form values. ASP.NET page and controls maintain their state by in hidden form field named _ViewState. By default it is enable for all server controls and sometimes create problem because unnecessary data are stored in this field. To minimize the size of the ViewState data, set EnableViewState to false.




Q.9 Debug class is available in which namespace?

A) System.Debug
B) System.Data
C) System.Diagnostics
D) None of the above
View Answer / Hide Answer

ANSWER: C

Explanation:

Debug class provides feedback about your code. These classes can be used because stepping through code in other ways is time consuming. For Debug class to function, the build must be performed in Debug mode




Q.10 You noticed that clicking a CheckBox does not cause an automatic PostBack. How do you make the CheckBox cause an automatic PostBack?

A) Set the AutoPostBack property to true.
B) Add JavaScript code to call the ForcePostBack method.
C) Set the PostBackAll property of the Web page to true.
D) None of the above
View Answer / Hide Answer

ANSWER: A




Q.11 What happens in the Init event of a page?

A) ViewState is loaded on the page.
B) Each child control of the page is initialized to its design time values.
C) HTML is rendered.
D) None of the above.
View Answer / Hide Answer

ANSWER: B




Q.12 To group multiple RadioButton controls together, which property will you set for each RadioButton control in the group?

A) Specify the same GroupName for each RadioButton.
B) Specify the different GroupName for each RadioButton.
C) Specify the same GroupID for each RadioButton.
D) Specify the same ID for each RadioButton.
View Answer / Hide Answer

ANSWER: A

Explanation:

GroupName property enables you to group RadioButton controls. Suppose that you have 10 RadioButtons and you want to create two different group of 5 RadioButton in each group. You have to provide same groupname to 5 RadioButton (Example GroupName=color) and another name but same for remaining 5 button (Example GroupName=City)




Q.13 What are the types of Web server Button controls that can be created?

A) Only Submit buttons.
B) Only Command buttons.
C) Submit and command buttons.
D) None of the above.
View Answer / Hide Answer

ANSWER: C

Explanation:

A Button control by default is used as a submit button or a command button. A submit button simply performs a PostBack to the server. Button works as a command when you assign a value to its CommandName property.




Q.14 How do you create a TextBox for retrieving a password from a user?

A) Set TextMode property of the TextBox control to Secret.
B) Set Mode property of the TextBox control to Password.
C) Set Text property of the TextBox control to Password.
D) Set TextMode property of the TextBox control to Password.
View Answer / Hide Answer

ANSWER: D

Explanation:

The TextBox control contains a TextMode property that has the following options as:
- SingleLine (default).
- MultiLine.
- Password.

When you set the TextMode property as a Password, it will work as a password textbox.




Q.15 In Design view, what is the easiest way to create an event handler for the default event of a server control?

A) Open the code-behind page and write the code.
B) Right-click the control and select Create Handler.
C) Drag an event handler from the Toolbox to the desired control.
D) Double-click the control.
View Answer / Hide Answer

ANSWER: D




Q.16 Match the following List 1 to List 2

List 1----------------------List 2
a. Literal Control----------i. SingleLine, MultiLine, Password
b. Label Control------------ii. CommandName
c. TextBox Control----------iii. Convert to span tag in HTML
d. Button Control-----------iv. PassThrough, Encode, Transform mode

Codes:

A) a-iv, b-iii, c-ii, d-i
B) a-ii, b-iv, c-i, d-iii
C) a-ii, b-i, c-iii, d-iv
D) a-iv, b-iii, c-i, d-ii
View Answer / Hide Answer

ANSWER: D




Q.17 Using which type of stylesheet we can change the style of an element in the entire website?

A) Internal Stylesheet
B) External Stylesheet
C) Inline stylesheet
D) None of these above
View Answer / Hide Answer

ANSWER: B




Q.18 Match the following List 1 to List 2

List 1(Controls)--------List 2
a. Image----------------i. Navigate, PostBack, Inactive HotSpotMode
b. ImageButton----------ii. Container control
c. ImageMap-------------iii. Has command event
d. MultiView------------iv. Does not have click event

Codes:

A) a-iv, b-iii, c-i, d-ii
B) a-ii, b-iv, c-i, d-iii
C) a-ii, b-i, c-iii, d-iv
D) a-iv, b-iii, c-i, d-ii
View Answer / Hide Answer

ANSWER: A




Q.19 A web page has lots of input data, and you want the data input to be spread across multiple screens. What is the best control to use to implement this solution on a single Web page?

A) ImageMap
B) Panel
C) Wizard
D) None of the above.
View Answer / Hide Answer

ANSWER: C

Description:

The Wizard control is used to divide a large form, which has the lots of data, into multiple sub-forms. The Wizard control contains one or more WizardStep child controls. Only one WizardStep is displayed at a time.


Post your comment