Friday, March 26, 2010

.NET 4 ASP.NET WebDev 70-515 Exam Prep Catto Crackin # 10

 

Hey Now Everybody,

In this 11th post of the Catto Code Crackin series we’ll continue with the section ‘real world exam question concepts’. In the .NET 3.5  * the .NET 4 exam there are questions. Let’s inspect some concepts & properties that will be the skills measured.

        Microsoft announced the .NET 4.0 Beta Exams on St. Patrick’s Day which are a free exam & if passed you get certified. Much of the study & prep materials are not available yet, therefore I’ve been studying for a similar exam 70-562 which is the .NET 3.5 ASP.NET Application Development. I hope by posting this content it will help myself along with other people in the community learn & get excited about .NET 4. If you are serious about studying for a MS Exam 2 must have resources: the Self Paced training books are a great books to buy along with practice exams from eBay.

Hey Now Everybody,

In this 10th post of the Catto Code Crackin series we’ll continue with the section ‘real world exam question concepts’. In the .NET 3.5  * the .NET 4 exam there are questions. Let’s inspect some concepts & properties that will be the skills measured.

        Microsoft announced the .NET 4.0 Beta Exams on St. Patrick’s Day which are a free exam & if passed you get certified. Much of the study & prep materials are not available yet, therefore I’ve been studying for a similar exam 70-562 which is the .NET 3.5 ASP.NET Application Development. I hope by posting this content it will help myself along with other people in the community learn & get excited about .NET 4. If you are serious about studying for a MS Exam 2 must have resources: the Self Paced training books are a great books to buy along with practice exams from eBay.

---------------------------------------------------------

QUESTION 54 cUSTOM SERVER CONTROLS
create a FormView control to access the results of a query.
The query contains the following fields:
EmployeID
FirstNam
LastNam

The user must be able to view and update the FirstName field.
define the control definition for the FirstName field in the FormView control.

C. <asp:TextBox ID="EditFirstNameTextBox" RunAt="Server" Text='<%# Bind("FirstName") %>' />

QUESTION 55 Data  Databinding
The application contains a DataSourceControl named CategoriesDataSource that is bound to a SQL Server 2005 table.
The CategoryName column is the primary key of the table.
FormView control:
01 <tr>
02 <td align="right"><b>Category:</b></td>
03 <td><asp:DropDownList ID="InsertCategoryDropDownList"
04
05 DataSourceID="CategoriesDataSource"
06 DataTextField="CategoryName"
07 DataValueField="CategoryID"
08 RunAt="Server" />
09 </td>
10 </tr>
Ensure that the changes made to the CategoryID field can be written to the database.
insert at line 04 the code:

B. SelectedValue='<%# Bind("CategoryID") %>'

56 QUESTION 56  Server Controls

You create a Web page to display photos and captions.
The caption of each photo in the database can be modified by using the application.

<asp:FormView DataSourceID="ObjectDataSource1" DataKeyNames="PhotoID" runat="server">
<EditItemTemplate>
<asp:TextBox Text='<%# Bind("Caption") %>' runat="server"/>
<asp:Button Text="Update" CommandName="Update" runat="server"/>
<asp:Button Text="Cancel" CommandName="Cancel" runat="server"/>
</EditItemTemplate>
<ItemTemplate>
<asp:Label Text='<%# Eval("Caption") %>' runat="server" />
<asp:Button Text="Edit" CommandName="Edit" runat="server"/>
</ItemTemplate>
</asp:FormView>
the application throws an error.
Ensure that the application successfully updates each caption and stores it in the database.

B. Add the ID attribute to the TextBox control.

QUESTION 57  web.config  defaultRedirect & error codes

The application contains two HTML pages named ErrorPage.htm and PageNotFound.htm.
Ensure that the following requirements are met:
When the userrequests a page that does not exist, the PageNotFound.htm page is displayed.
When any other error occurs, the ErrorPage.htm page is displayed.
Web.config file
B. <customErrors mode="On" defaultRedirect="ErrorPage.htm"> <error statusCode="404" redirect="PageNotFound.htm"/> </customErrors>

QUESTION 58  web.config debug="false"

Deploy the application to a test server.
Ensure that during the initial request to the application, the code-behind files for the Web pages are compiled.
You also need to optimize the performance of the application.
Web.config

B. <compilation debug="false">

59 QUESTION 59 Debuggin remotely w3wp.exe

You host the application on a server named ContosoTest that runs Microsoft IIS 6.0.
You set up remote debugging on the ContosoTest server.
Debug the application remotely from another computer named ContosoDev.

A. Attach Microsoft Visual Studio.NET to the w3wp.exe process.

QUESTION 60 Remote Debugging Server Admin group
The application resides on a server named ContosoTest that runs Microsoft IIS 5.0.
You use a computer named ContosoDev to log on to the Contoso.com domain with an account named ContosoUser.
The ContosoTest and ContosoDev servers are members of the Contoso.com domain.
Set up the appropriate permission for remote debugging.

C. Add the ContosoUser account to the local Administrators group on the ContosoTest server.

QUESTION 61 Debugging Trace Dump
You attach Microsoft VS08 debugger to IE instance to debug the JavaScript code in the AJAX application.
Ensure that the app displays the details of the client-side object on the debugger console:

D. Use the Sys.Debug.traceDump method.

QUESTION 62  IE Script Debugging  Options

A JavaScript code segment in the AJAX application does not exhibit the desired behavior.
IE displays an error icon in the status bar but does not prompt you to debug the script.
Configure IE to prompt you to debug the script.

B. Clear the Disable Script Debugging (Internet Explorer) check box.

E. Select the Display a notification about every script error check box.

63 QUESTION 63 Web.Config Trace

Capture the timing and performance information of the application.
Ensure that the information is accessible only when the user is logged on to the Web server and not on individual Web pages.
Web.config:

C. <trace enabled="true" pageOutput="false" localOnly="true" />

64 QUESTION 64
Access the application in a Web browser, you receive the following error message:
"Service Unavailable".
Access the application successfully by:

B. Starting the Application pool.

65 QUESTION 65  web.config impersonate

The application is deployed on a Microsoft IIS 6.0 Web server by using the default ASP.NET version 2.0 application pool and Windows Authentication.
The application contains functionality to upload files to a location on a different server.
Users receive an access denied error message when they attempt to submit a file.
Web.config file code below will resolve the error:

A. <identity impersonate="true" />

66
QUESTION 66
When you review the application performance counters, you discover that there is an unexpected increase in the value of the Application Restarts counter.
identify the reasons for this increase
Possible reasons that could cause this increase?

C. Addition of a new assembly in the Bin directory of the application.
D. Addition of a code segment that requires recompilation to the ASP.NET Web application.

F. Modification to the Web.config file in the system.web section for debugging the application.
QUESTION 67     Web.config HealthMonitoring
Monitor the execution of the application at daily intervals.
Modify the application configuration to enable WebEvent monitoring.

D. <healthMonitoring enabled="true" heartbeatInterval="10">
<rules>
<add name="Heartbeats Default" eventName="Heartbeat" provider="EventLogProvider" profile="Critical"/>
</rules>
</healthMonitoring>

QUESTION 68  Web.config System.Web.Management.WebAuditEvent & .webErrorEvent
Web.config:
01 <healthMonitoring>
02 <providers>
03 <add name="EventLogProvider"
04 type="System.Web.Management.EventLogWebEventProvider
05 />
06 <add name="WmiWebEventProvider"
07 type="System.Web.Management.WmiWebEventProvider
08 />
09 </providers>
10 <eventMappings>
11
12 </eventMappings>
13 <rules>
14 <add name="Security Rule" eventName="Security Event"
15 provider="WmiWebEventProvider" />
16 <add name="AppError Rule" eventName="AppError Event"
17 provider="EventLogProvider" />
18 </rules>
19 </healthMonitoring>
Configure Web Events to meet the following requirements:
Security-related Web Events are mapped to Microsoft Windows Management Instrumentation (WMI) events.
Web Events caused by problems with configuration or application code are logged into the Windows Application Event Log.
insert at line 11 the following code:

B. <add name="Security Event"type="System.Web.Management.WebAuditEvent"/>
<add name="AppError Event"type="System.Web.Management.WebErrorEvent"/>

69 QUESTION 69 controls AsyncPostBackTrigger & PostBackTrigger
.aspx page:
01 <asp:UpdatePanel ID="upnData" runat="server"
02 ChildrenAsTriggers="false" UpdateMode="Conditional">
03 <Triggers>
04
05 </Triggers>
06 <ContentTemplate>
07 <!-- more content here -->
08 <asp:LinkButton ID="lbkLoad" runat="server" Text="Load"
09 onclick="lbkLoad_Click" />
10 <asp:Button ID="btnSubmit" runat="server" Text="Submit"
11 Width="150px" onclick="btnSubmit_Click" />
12 </ContentTemplate>
13 </asp:UpdatePanel>
14 <asp:Button ID="btnUpdate" runat="server" Text="Update"
15 Width="150px" onclick="btnUpdate_Click" />
Ensure that the requirements are met:
lbkLoad & btUpdate asyncronous postback to upnData
btnSubmit - syncronous postback

D. Set the value of the ChildrenAsTriggers property in line 02 to true.
Add the following code fragment at line 04.
<asp:AsyncPostBackTrigger ControlID="btnUpdate" /> <asp:PostBackTrigger ControlID="btnSubmit" />

70  AJAX <asp:AsyncPostBackTrigger
01 <asp:ScriptManager ID="scrMgr" runat="server" />
02 <asp:UpdatePanel ID="updPanel" runat="server"
03 UpdateMode="Conditional">
04 <ContentTemplate>
05 <asp:Label ID="lblTime" runat="server" />
06 <asp:UpdatePanel ID="updInnerPanel"
07 runat="server" UpdateMode="Conditional">
08 <ContentTemplate>
09 <asp:Timer ID="tmrTimer" runat="server"
10 Interval="1000"
11 OnTick="tmrTimer_Tick" />
12 </ContentTemplate>
13
14 </asp:UpdatePanel>
15 </ContentTemplate>
16
17 </asp:UpdatePanel>
The tmrTimer_Tick event handler sets the Text property of the lblTime Label control to the current time of the server.
Configure the appropriate UpdatePanel control to ensure that the lblTime Label Control is properly updated by the tmrTimer Timer control.

D. Add the following code fragment to line 16.
<Triggers> <asp:AsyncPostBackTrigger ControlID="tmrTimer" EventName="Tick" /> </Triggers>

71 QUESTION 71 AJAX
01 function updateLabelControl(labelId, newText) {
02 var label = $find(labelId);
03 label.innerHTML = newText;
04 }
The client script function uses ASP.NET AJAX and updates the text of any Label control in the Web form.
When you test the client script function, you discover that the Label controls are not updated.
JavaScript error message in the browser: "'null' is null or not an object." You need to resolve the error.

B. Replace line 02 with the following line of code.
var label = $get(labelId);

72  AJAX .jx
You write the following client-script code fragment to handle the exceptions thrown from asynchronous postbacks.
01 <script type="text/javascript">
02 function pageLoad()
03 {
04 var pageMgr =
05 Sys.WebForms.PageRequestManager.getInstance();
06
07 }
08
09 function errorHandler(sender, args)
10 {
11
12 }
13 </script>
Ensure that the application performs the following tasks:
Use a common clien-script function named errorHandler.
Update a Label control that has an ID named lblEror with the error message.
Prevent the browser from displaying any message box or Javascript error

A. Insert the following code segment at line 06.
pageMgr.add_endRequest(errorHandler);
Insert the following code segment at line 11.
if (args.get_error() != null) {
$get('lblError').innerHTML = args.get_error().message;
args.set_errorHandled(true);
}

73 ajax $get
01 <script type="text/javascript">
02
03 Sys.Application.add_init(initComponents);
04
05 function initComponents() {
06
07 }
08
09 </script>
10
11 <asp:ScriptManager ID="ScriptManager1"
12 runat="server" />
13 <asp:TextBox runat="server" ID="TextBox1" />
Create and initialize a client behavior named MyCustomBehavior by using the initComponents function. You also need to ensure that
MyCustomBehavior is attached to the TextBox1 Textbox control.
insert at line 06 the following code:

B. $create(MyCustomBehavior, null, null, null, $get('TextBox1'));

74 AJAX Authentication
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:TextBox runat="server" ID="txtUser" Width="200px" />
<asp:TextBox runat="server" ID="txtPassword" Width="200px" />
<asp:Button runat="server" ID="btnLogin" Text="Login" OnClientClick="login(); return false;" />
When a user clicks the btnLogin Button control, the login() client-side script is called to authenticate the user. The credentials provided in the TextBox cont
used to call the client-side script.

.js file:
01 <script type="text/javascript">
02 function login() {
03 var username = $get('txtUser').value;
04 var password = $get('txtPassword').value;
05
06 // authentication logic.
07 }
08 function onLoginCompleted(validCredentials, userContext,
09 methodName)
10 {
11 // notify user on authentication result.
12 }
13
14 function onLoginFailed(error, userContext, methodName)
15 {
16 // notify user on authentication exception.
17 }
18 </script>
The ASP.NET application is configured to use Forms Authentication. The ASP.NET AJAX authentication service is activated in the Web.config file.
Ensure that the following workflow is maintained:
On successful authentication, the onLoginCompleted clien-script function is called to notify the user.
On failure of authentication, the onLoginFailed clien-script function is called to display an error message.

Insert at line 06 the following code
A. var auth = Sys.Services.AuthenticationService;
auth.login(username, password, false, null, null,onLoginCompleted, onLoginFailed, null);

QUESTION 75 web.configDeviceSpecific
Web.config file.
<filter name="isHtml" compare="PreferredRenderingType"argument="html32" />
The application contains a Web page that has the following image control. (Line numbers are included for reference only.)
01 <mobile:Image ID="imgCtrl" Runat="server">
02
03 </mobile:Image>
You need to ensure that the following conditions are met:
The imgCtrl Image control displays the highRes.jpg file if the Web browser supports html
The imgCtrl Image control displays lowRes.gif if the Web broser does not support html.

Insert at line 02 the following code:
A. <DeviceSpecific>
<Choice Filter="isHtml" ImageUrl="highRes.jpg" />
<Choice ImageUrl="lowRes.gif" />
</DeviceSpecific>

76  Mobile
<mobile:StyleSheet id="MyStyleSheet" runat="server">
<mobile:Style Name="StyleA" Font-Name="Arial" Font-Bold="True" Wrapping="NoWrap">
</mobile:Style>
</mobile:StyleSheet>
Add a Label control named MyLabel that uses the defined style in the MyStyleSheet StyleSheet control.

A. <mobile:Label ID="MyLabel" Runat="server"StyleReference="MyStyleSheet:StyleA"> </mobile:Label>

77 QUESTION 77 web.config Themes/
You modify an existing Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You add a theme to the ASP.NET application.
You need to apply the theme to override any settings of individual controls.

A. In the Web.config file of the application, set the Theme attribute of the pages element to the name of the theme.

78 Themes
The application uses 10 themes and allows the users to select their themes for the Web page.
When a user returns to the application, the theme selected by the user is used to display pages in the application. This occurs even if the user returns to log on at a
later date or from a different client computer.
The application runs on different storage types and in different environments.
You need to store the themes that are selected by the users and retrieve the required theme.

G. Add a setting for the theme to the profile section of the Web.config file of the application.
H. Use the Profile.Theme string theme to store the name of the theme that is selected by the user.

79 URL Routing
The application must redirect the original URL to a different ASPX page.
Ensure that the users cannot view the original URL after the page is executed.
You also need to ensure that each page execution requires only one request from the client browser.

C. Use the HttpContext.Current.RewritePath method to transfer execution to the correct ASPX page.

80 Data
The application uses Session objects. You are modifying the application to run on a Web farm.
Ensure that the application can access the Session objects from all the servers in the Web farm.
You also need to ensure that when any server in the
Web farm restarts or stops responding, the Session objects are not lost.
B. Use the SQLServer Session Management mode to store session data in a common Microsoft SQL Server 2005 database.

81
web.config
The Web site uses C# as the programming language.
You plan to add a code file written in Microsoft VB.NET to the application.
This code segment will not be converted to C#.
Web.config\
<compilation debug="false">
<codeSubDirectories>
<add directoryName="VBCode"/>
</codeSubDirectories>
</compilation>
You need to ensure that the following requirements are met:
The existing VB.NET file can be used in the Web application The file can be modified and compiled at run time What should you do?
B. Create a new folder named VBCode inside the App_Code folder of the application Place the VB.NET code file in this new folder

82 .web.config
The application uses a set of general-purpose utility classes that implement business logic.
These classes are modified frequently.
Ensure that the application is recompiled automatically when a utility class is modified.

A. Create the Web application by using a Microsoft Visual Studio ASP.NET Web site Add the utility classes to the App_Code subfolder of the Web application

83 Custom Server Controls web.config Cashing
You add a Web page named HomePage.aspx in the application. The Web page contains different controls.
You add a newly created custom control named CachedControl to the Web page.
You need to ensure that the following requirements are met:
The custom control state remains static for one minute The custom control settings do not affect the cache settings of other elements in the Web page What
A. Add the following code fragment to the Web.config file of the solution.
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="CachedProfileSet" varyByControl="CachedControl" duration="60" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>

That is all there will be more,

Catto

No comments: