Question 4) TS: Microsoft .NET Framework 2.0

Posted on
Like what you see? Share it.Share on Google+Share on LinkedInShare on FacebookShare on RedditTweet about this on TwitterEmail this to someone

 

Objective: Customizing and Personalizing a Web Application
SubObjective: Implement Web Parts in a Web Application

 

Single Answer Multiple Choice

 

You are a Web application developer for a company. You are creating an ASP.NET application to be used by company employees to track inventory data.

 

You add following code to DisplayProduct.aspx Web page:

 

<asp:WebPartManager ID=”WebPartManager1″ runat=”server” />

 

<asp:Label ID=”Label1″ runat=”server” Text=”Label” />

 

<asp:WebPartZone ID=”WebPartZone1″ runat=”server”>

 

<ZoneTemplate>

 

<asp:HyperLink ID=”HyperLink1″ runat=”server”

 

NavigateUrl=”www.microsoft.com”>

 

Click to visit Microsoft.com

 

</asp:HyperLink>

 

<asp:Image ID=”Image1″ runat=”server”

 

ImageUrl=”~/Images/Map.JPG” />

 

</ZoneTemplate>

 

</asp:WebPartZone>

 

You want to display current mode the user is in when viewing WebPart controls and display that mode using a Label Web server control named Label1.

 

Which code will you use to display current viewing mode of WebPart controls on DisplayProduct.aspx?

 

A. Label1.Text = WebPartManager1.DisplayMode
B. Label1.Text = WebPartManager1.DisplayMode.Name
C. Label1.Text = WebPartManager1.WebParts.DisplayMode
D. Label1.Text = WebPartManager.BrowseDisplayMode.Name

 

Answer:
B. Label1.Text = WebPartManager1.DisplayMode.Name

 

Tutorial:
You should use the following code:

 

Label1.Text = WebPartManager1.DisplayMode.Name

 

This code uses the DisplayMode property of the WebPartManager to retrieve the current viewing mode of WebPart controls on the DisplayProduct.aspx Web page. The DisplayMode property returns an instance of the WebPartDisplayMode class, so you must use DisplayMode.Name to display the name of the viewing mode as a String. To retrieve all available modes for a page’s WebParts, you can use the DisplayModes collection.

 

You should not use the following code:

 

Label1.Text = WebPartManager1.DisplayMode

 

This code is incorrect because the DisplayMode property returns an instance of the WebPartDisplayMode class, so you must use DisplayMode.Name to display the name of the viewing mode as a String.

 

You should not use the following code:

 

Label1.Text = WebPartManager1.WebParts.DisplayMode

 

This code is incorrect because the WebParts collection does not have a DisplayMode property. The WebParts collection does reference all WebPart controls on the page, but the each WebPart control’s display is determined by the WebPartManager. The DisplayMode is aproperty of the WebPartManager. The DisplayMode property returns an instance of the WebPartDisplayMode class, so you must use DisplayMode.Name to display the name of the viewing mode as a String. To retrieve all available modes for a page’s WebParts, you can use the DisplayModes collection. This code will generate a compile-time error.

 

You should not use the following code:

 

Label1.Text = WebPartManager.BrowseDisplayMode.Name

 

This code is incorrect because the BrowseDisplayMode property is a static field, and will always retrieve an object of type BrowseDisplayMode, regardless of the current view mode of WebPart controls on the DisplayProduct.aspx Web page. You must use the DisplayMode property to return the current viewing mode of a Web page containing WebPart controls.

 

Reference:
MSDN2 Library, Search, “.NET Development,” “.NET Framework SDK,” “Class Library Reference,” “System.Web.UI.WebControls.WebParts,” “WebPartManager Class,” “WebPartManager Properties,” “DisplayMode Property.”

 

MSDN2 Library, Search, “.NET Development,” “.NET Framework SDK,” “Class Library Reference,” “System.Web.UI.WebControls.WebParts,” “WebPart Class.”

 

These questions are derived from the Self Test Software Practice Test for Microsoft exam #70-528 – TS: Microsoft .NET Framework 2.0 – Web-Based Client Development (VB.NET)

Like what you see? Share it.Share on Google+Share on LinkedInShare on FacebookShare on RedditTweet about this on TwitterEmail this to someone
cmadmin

ABOUT THE AUTHOR

Posted in Archive|

Comment: