10) You have developed an ASP.NET page that contains the following code:
<%@ Page Language="c#" AutoEventWireUp="true"
EnableViewState="true" SmartNavigation="false"%>
<html>
<script runat="server">
protected void Page_Load(Object o, EventArgs e)
{
if(!Page.IsPostBack)
{
// Populate the color drop-down list
ddlColor.Items.Add("Blue");
ddlColor.Items.Add("Red");
ddlColor.Items.Add("Green");
}
}
protected override void OnInit(EventArgs e)
{
this.Load += new EventHandler(Page_Load);
base.OnInit(e);
}
</script>
<body>
<form runat="server">
Select a Color:
<asp:DropDownList id="ddlColor"
runat="server" >
<asp:Button id="btnSubmit"runat="server" >
</form>
</body>
</html>
When you view the page in the browser, you find that the color names are displayed twice in the drop-down list. Which of the following options should you choose to solve this problem?
a) Modify the Page directive as follows:
<%@ Page Language="c#"
AutoEventWireUp="true"
EnableViewState="false"
SmartNavigation="false"%>
b) Modify the Page directive as follows:
<%@ Page Language="c#"
AutoEventWireUp="true"
EnableViewState="true"
SmartNavigation="true"%>
c) Modify the Page directive as follows:
<%@ Page Language="c#"
AutoEventWireUp="false"
EnableViewState="true"
SmartNavigation="false"%>
d) Modify the Page_Load() method as follows:
protected void Page_Load(Object o, EventArgs e)
{
if(Page.IsPostBack)
{
// Populate the color drop-down list
ddlColor.Items.Add("Blue");
ddlColor.Items.Add("Red");
ddlColor.Items.Add("Green");
}