Developing ASP.NET MVC Web Applications — Question 140
If the canvas element is supported by the client browser, the application must display "London 2012" in the footer as text formatted by JavaScript at the end of the
_Layout.cshtml file.
You need to modify the layout to ensure that "London 2012" is displayed as either formatted text or as plain text, depending on what the client browser supports.
Which code segment should you add?
Answer options
- A. <canvas id="myFooter"> @(Request,Browser.JavaApplets ? new HtmlString("London 2012") : null) </canvas>
- B. <canvas id="myFooter">London 2012</canvas>
- C. <canvas id="myCanvas">London 2012</canvas>
- D. <canvas id="myCanvas"></canvas> <p>London 2012</p>
Correct answer: C
Explanation
The correct answer is C because it correctly displays 'London 2012' within a canvas element, which is the requirement when the browser supports it. Option A is incorrect because it includes unnecessary conditional logic for Java applets, while option B does not leverage the canvas for formatting. Option D uses a paragraph tag but does not utilize the canvas element for displaying the text.