Chapter 10 Navigator.aspx problem
Hi,
I am working on the Try it Out example - Navigator.aspx. Following is the code I copied from the book:
<%@ page Language="c#" %>
<script Language="c#" runat="server">
void Page_Load(object source, EventArgs e)
{
if (!IsPostBack)
{
MyButton.Text = "OK";
MyDropDownList.Items.Add("http://www.microsoft.com");
MyDropDownList.Items.Add("http://www.wrox.com");
MyDropDownList.Items.Add("http://msdn.microsoft.com");
}
}
</script>
<html>
<body>
<form id="WebForm1" method="post" runat="server">
<asp:DropDownList ID=MyDropDownList runat="server" />
<asp:button ID=MyButton runat="server" Text="" />
</form>
</body>
</html>
When I open it from the browser I should see the button with 'OK' and the three urls in the dropdown list. But that's not happening. I can't see anything. If I take away the '!' mark from
if (!(IsPostBack)) statement [which is [if (IsPostBack)], I can see the button with 'OK' and the 3 urls. If I click the OK button it will add another 3 urls to the dropdown list. Could anybody tell what is going on here. Thanks a lot.
|