Friday, March 26, 2010

.NET 4 ASP.NET Web Dev 70-515 Exam Prep Catto Crackin # 9

Hey Now Everybody,

In this 9th 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 26 JS AssemblyInfo.cs
JavaScript file named CalculatorScript.js.
function divide(a, b) {
if (b == 0) {
var errorMsg = Messages.DivideByZero;
alert(errorMsg); return null;
return a/b;
You embed the CalculatorScript.js file as a resource in a Class Library project.
The namespace for this project is Calculator.Resources.
The JavaScript function retrieves messages from a resource file named MessageResources.resx by using the JavaScript Messages object.
You add an AJAX Web form in the ASP.NET application. You reference the Class Library in the application.
You add an ASP.NET AJAX ScriptReference element to the AJAX Web form.
You need to ensure that the JavaScript function can access the error messages that are defined in the resource file.
You add in the AssemblyInfo.cs file the following:
C. [assembly: ScriptResource ("Calculator.Resources.CalculatorScript.js", "Calculator.Resources.MessageResources", "Messages")]

QUESTION 27 AJAX Asynchronouse Postback
AJAX-enabled Web form by using the following code fragment.

<asp:ScriptManager ID="scrMgr" runat="server" />
<asp:UpdatePanel runat="server" ID="updFirstPanel" UpdateMode="Conditional">
<asp:TextBox runat="server" ID="txtInfo" />
<asp:Button runat="server" ID="btnSubmit" Text="Submit" />
<asp:UpdatePanel runat="server" ID="updSecondPanel" UpdateMode="Conditional">
<ContentTemplate> ...
When the updFirstPanel UpdatePanel control is updated, a dynamic client script is registered.
You write the following code segment in the code-behind file of the Web form. (Line numbers are included for reference only.)
01 protected void Page_Load(object sender, EventArgs e)
02 {
03 if(IsPostBack)
04 {
05 string generatedScript = ScriptGenerator.GenerateScript();
07 }
08 }
Ensure that the client-script code is registered only when an asynchronous postback is issued on the updFirstPanel UpdatePanel control.
you insert at line 06 the following code:

D. ScriptManager.RegisterClientScriptBlock(txtInfo, typeof(TextBox), "txtInfo_Script", generatedScript, false);

QUESTION 28  Config & Verify siz of the devcie deplay char
public class CapabilityEvaluator {
public static bool ChkScreenSize( System.Web.Mobile.MobileCapabilities cap, String arg) {
int screenSize = cap.ScreenCharactersWidth * cap.ScreenCharactersHeight;
return screenSize < int.Parse(arg);
Add the following device filter element to the Web.config file:
<filter name="FltrScreenSize" type="MyWebApp.CapabilityEvaluator,MyWebApp" method="ChkScreenSize" />

write a code segment to verify whether the size of the device display is less than 80 characters

A. MobileCapabilities currentMobile; currentMobile = Request.Browser as MobileCapabilities;
if(currentMobile.HasCapability("FltrScreenSize","80")) {

QUESTION 29 Mobile
a mobile Web form:
ObjectList control.

<mobile:ObjectList ID="ObjectListCtrl" OnItemCommand="ObjectListCtrl_ItemCommand" Runat="server">
<Command Name="CmdDisplayDetails" Text="Details" />
<Command Name="CmdRemove" Text="Remove" />

Ccreate an event handler named ObjectListCtrl_ItemCommand.
Ennsure that the ObjectListCtrl_ItemCommand handler detects the selection of the CmdDisplayDetails item.
Code you should use:
A. public void ObjectListCtrl_ItemCommand( object sender, ObjectListCommandEventArgs e) {
if (e.CommandName == "CmdDisplayDetails") {
} }

30 QUESTION 30  Master Pages NavContent Pages
ll the content pages in the application use a single master page.
The master page uses a static navigation menu to browse the site.
You need to ensure that the content pages can optionally replace the static navigation menu with their own menu controls.

B. Add the following code fragment to the master page
<asp:ContentPlaceHolder ID="MenuPlaceHolder" runat="server"> <!-- Menu code here -->
Add the following code fragment to the content page <asp:Content ContentPlaceHolderID="MenuPlaceHolder"> <asp:menu ID="menuControl" runat="server">
</ asp: menu </asp:Content>

31 QUESTION 31  SQLDataSource sqlds IP address captured

The application allows users to post comments to a page that can be viewed by other users.
You add a SqlDataSource control named SqlDS
1. You write the following code segment. (Line numbers are included for reference only.)
01 private void SaveComment()
02 {
03 string ipaddr;
05 SqlDS1.InsertParameters["IPAddress"].DefaultValue = ipaddr;
06 ...
07 SqlDS1.Insert();
08 }
Ensure that the IP Address of each user who posts a comment is captured along with the user's comment
insert at line 04  the following code:

D. ipaddr = Request.ServerVariables["REMOTE_ADDR"].ToString();

32  resx resource file
Create a Web page named Default.aspx in the root of the application.
Add an ImageResources.resx resource file in the App_GlobalResources folder. The
ImageResources.resx file contains a localized resource named LogoImageUrl.
Retrieve the value of LogoImageUrl.
code segment you should use:
C. string logoImageUrl = (string)GetGlobalResource("ImageResources", "LogoImageUrl");

create a custom Web user control named SharedControl.
The control will be compiled as a library.
You write the following code segment for the SharedControl control.
01 protected override void OnInit(EventArgs e)
02 {
03 base.OnInit(e);
05 }
All the master pages in the ASP.NET application contain the following directive.
<%@ Master Language="C#" EnableViewState="false" %>
You need to ensure that the state of the SharedControl control can persist on the pages that reference a master page.
You insert at line 04 the code;

B. Page.RegisterRequiresControlState(this);

a Web page that has a GridView control named GridView1.
The GridView1 control displays the data from a database named Region and a table named
write the following code segment to populate the GridView1 control.
01 protected void Page_Load(object sender, EventArgs e)
02 {
03 string connstr;
05 SqlDependency.Start(connstr);
06 using (SqlConnection connection =
07 new SqlConnection(connstr))
08 {
09 SqlCommand sqlcmd = new SqlCommand();
10 DateTime expires = DateTime.Now.AddMinutes(30);
11 SqlCacheDependency dependency = new
12 SqlCacheDependency("Region", "Location");
13 Response.Cache.SetExpires(expires);
14 Response.Cache.SetValidUntilExpires(true);
15 Response.AddCacheDependency(dependency);
17 sqlcmd.Connection = connection;
18 GridView1.DataSource = sqlcmd.ExecuteReader();
19 GridView1.DataBind();
20 }
21 }
ensure that the proxy servers can cache the content of the GridView1 control.
Which code segment should you insert at line 16?
B. Response.Cache.SetCacheability(HttpCacheability.Public);

QUESTION 35 Server Controls Calendar
.aspx page contorl
<asp:Calendar EnableViewState="false"ID="calBegin" runat="server" />
.cs file
void LoadDate(object sender, EventArgs e) {
if (IsPostBack) {
calBegin.SelectedDate = (DateTime)ViewState["date"];
void SaveDate(object sender, EventArgs e) {
ViewState["date"] = calBegin.SelectedDate;
Ensure that the calBegin Calendar control maintains the selected date.
You insert in the constructor of the page the following:

D. this.Load += new EventHandler(LoadDate); this.PreRender += new EventHandler(SaveDate);

36 QUESTION 36 Server Controls Listbox
.aspx page
<asp:ListBox ID="lstLanguages"AutoPostBack="true" runat="server" />

.cs file
void BindData(object sender, EventArgs e) {
lstLanguages.DataSource = CultureInfo.GetCultures(CultureTypes.AllCultures);
lstLanguages.DataTextField = "EnglishName"; lstLanguages.DataBind();
Ensure that the lstLanguages ListBox control maintains the selection of the user during postback.
insert in the constructor the following code:

A. this.Init += new EventHandler(BindData);

37   URL Routing
The web app is using IIS 6  file is named oldPage.aspx.
Ensure that the following requirements are met when a user attempts to access the page:
The browser diplays the URL of the oldPage.aspx page.
The browser displays the page named newPage.aspx

A. Server.Transfer("newPage.aspx");
38 QUESTION 38      Server Controls Textbox

enterName.aspx. The Web page contains a TextBox control named txtName. The Web page cross posts to a page named
displayName.aspx that contains a Label control named lblName.
Ensure that the lblName Label control displays the text that was entered in the txtName TextBox control.

D. TextBox txtName = PreviousPage.FindControl("txtName") as TextBox;
    lblName.Text = txtName.Text;

39 QUESTION 39  Web.Config

A class named MultimediaDownloader that implements the IHttpHandler interface:
namespace Contoso.Web.UI {
public class MultimediaDownloader : IHttpHandler {
} }

The MultimediaDownloader class performs the following tasks:
It returns the content of the multimedia files from the Web server
It processes requests for the files that have the .media file extension The .media file extension is
mapped to the aspnet_isapi.dll file in Microsoft IIS 6.0.
Configure the MultimediaDownloader class in the Web.config file of the application.

C. <httpHandlers> <add verb="*" path="*.media" validate="false" type="Contoso.Web.UI.MultimediaDownloader" /> </httpHandlers>

#40 Content Type Image displayed when handler is requested
A class that implements the IHttpHandler interface.
You implement the ProcessRequest method :

01 public void ProcessRequest(HttpContext ctx) {
03 }
Ensure that the image named Alert.jpg is displayed in the browser when the handler is requested.
Insert at line 02 the following code:

C. ctx.Response.ContentType = "image/jpg";
FileStream fs = File.OpenRead(ctx.Server.MapPath("Alert.jpg"));
int b;
while ((b = fs.ReadByte()) != -1) {

QUESTION 41 Membership, SQL Server & aspnet_regsql.exe

Computer that hosts the ASP.NET Web application contains a local instance of Microsoft SQL Server 2005.
The instance uses Windows Authentication.
You plan to configure the membership providers and the role management providers.
Install the database elements for both the providers on the local computer.

D. Run the aspnet_regsql.exe -E -S localhost -A mr command from the command line.

QUESTION 42 Roles Identity Imersonate

Windows Authentication
You set up NTFS file system permissions for the Sales group to access a particular file.
You discover that all the users are able to access the file.
Ensure that only the Sales group users can access the file.

C. Add the <identity impersonate="true"/> section to the Web.config file.

QUESTION 43 Authentication <deny users="?" />
Set up authentication for the Web application.
The application must support users from untrusted domains.
Ensure that anonymous users cannot access the application.

A. <system.web> <authentication mode="Forms"> <forms loginUrl="login.aspx" /> </authentication> <authorization> <deny users="?" /> </authorization> </system.

QUESTION 45 Framework Versions IIS6
ASP.NET 1.0 app that does not use any features that are deprecated in the Microsoft .NET 3.5.
The application runs on Microsoft IIS 6.0.
Configure the application to use the ASP.NET Framework version 3.5 without recompiling the application.

A. Edit the ASP.NET runtime version in IIS 6.0.

QUESTION 46 AJAX SessionState CookieLess Use Cookies

ASP.NET AJAX, and you plan to deploy it in a Web farm environment.
Configure SessionState for the application.

C. <sessionState mode="SQLServer"cookieless="UseCookies" sqlConnectionString="Integrated Security=SSPI;data source=MySqlServer;"/>

QUESTION 47 .NET Framework Versions & IIS6

Deploy the application on a Microsoft IIS 6.0 Web server.
The server runs on a worker process isolation mode, and it hosts the .NET 1.1 Web applications.
When you attempt to browse the application, the following error message is received:
"It is not possible to run different versions of ASP.NET in the same IIS process. Please use the IIS Administration Tool to reconfigure your server to run the
application in a separate process."
Ensure that the following requirements are met:
All the applications run on the server All the applications remain in process isolation mode All the applications do not change their configuration.

A. Create a new application pool and add the new application to the pool.
C. Configure the new application to use the .NET Framework version 2.0 in the IIS 6.0 Manager.

QUESTION 48 Data Insert DataKeyNames & PKs
The MovieReviews.aspx file connects to a LinqDataSource DataSource named LinqDataSource1 that has a primary key named MovieID.
DetailsView control named DetailsView1.
01 <asp:DetailsView ID="DetailsView1" runat="server"
02 DataSourceID="LinqDataSource1"
04 />
05 <Fields>
06 <asp:BoundField DataField="MovieID" HeaderText="MovieID"
07 InsertVisible="False"
08 ReadOnly="True" SortExpression="MovieID" />
09 <asp:BoundField DataField="Title" HeaderText="Title"
10 SortExpression="Title" />
11 <asp:BoundField DataField="Theater" HeaderText="Theater"
12 SortExpression="Theater" />
13 <asp:CommandField ShowDeleteButton="false"
14 ShowEditButton="True" ShowInsertButton="True" />
15 </Fields>
16 </asp:DetailsView>
Ensure that the users can insert and update content in the DetailsView1 control.
Prevent duplication of the link button controls for the Edit and New operations.
Insert at line 03 the following code:

B. AllowPaging="true" AutoGenerateRows="false" DataKeyNames="MovieID"

QUESTION 49 Custom Server Controls INamingContainer

A custom-templated server control.
Ensure that the child controls of the server control are
uniquely identified within the control hierarchy of the page.
Implement the following interface:

B. the INamingContainer interface

QUESTION 50 Validation ErrorMessage

01 <asp:RequiredFieldValidator
02 ID="rfValidator1" runat="server"
03 Display="Dynamic" ControlToValidate="TextBox1"
05 >
07 </asp:RequiredFieldValidator>
09 <asp:ValidationSummary DisplayMode="List"
10 ID="ValidationSummary1" runat="server" />
Ensure that the error message displayed in the validation control
is also displayed in the validation summary list.

C. Add the following code segment to line 04.
ErrorMessage="Required text in TextBox1"

QUESTION 51 Web.Config pages validateRequest

You plan to submit text that contains HTML code to a page in the application.
Ensure that the HTML code can be submitted successfully without affecting other applications that run on the Web server.

C. Set the following value in the Web.config file.
<system.web> <pages validateRequest="false"/> </system.web>

QUESTION 52 Web Service Communication
The application consumes an ASMX Web service.
The Web service is hosted at the following URL.
Ensure that the client computers can communicate with the service as part of the <system.
serviceModel> configuration.

B. <client> <endpoint address="http: //" binding="basicHttpBinding" / </client>

QUESTION 53 XML & TreeView Control

<Movie ID="1" Name="Movie1" Year="2006">
<Desc Value="Movie desc"/>
<Movie ID="2" Name="Movie2" Year="2007">
<Desc Value="Movie desc"/>
<Movie ID="3" Name="Movie3" Year="2008">
<Desc Value="Movie desc"/>

.aspx file:
01 <form runat="server">
02 <asp:xmldatasource
03 id="XmlDataSource1"
04 runat="server"
05 datafile="movies.xml" />
07 </form>
Implement the XmlDataSource control to display the XML data in a TreeView control.
insert at line 06 the following code:

A. <asp:TreeView ID="TreeView1" runat="server"DataSourceID="XmlDataSource1">
<asp:TreeNodeBinding DataMember="Movie" Text="Name" />

------------------------------------------------------------------------------ That is all, there will be more,


No comments: