Having a stupid problem

windows

Guest
I am learning how to use the Menu control in ASP.NET 2.0 So far I have been able to successfully make a SiteMap file and then have a Menu use that sitemapobject. The menu works perfectally... BUT when I try to set a callback method for the Event OnMenuItemClick ... the method is never invoked. What am I doing wrong?


<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Rental Tool Services</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table border="0" cellpadding="0" cellspacing="0" style="width: 973px; height: 426px">
<tr>
<td style="width: 209px" valign="top">

<asp:Menu ID="Menu1" runat="server" BackColor="#E3EAEB" DataSourceID="SiteMap" DynamicHorizontalOffset="2"
Font-Names="Verdana" Font-Size="0.95em" ForeColor="#666666" StaticSubMenuIndent="10px" Font-Bold="True" OnMenuItemClick="Menu1_MenuItemClick">
<StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<DynamicHoverStyle BackColor="#666666" ForeColor="White" />
<DynamicMenuStyle BackColor="#E3EAEB" />
<DynamicItemTemplate>
<%# Eval("Text") %>
</DynamicItemTemplate>
<StaticSelectedStyle BackColor="Goldenrod" />
<DynamicSelectedStyle BackColor="#1C5E55" />
<DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<StaticHoverStyle BackColor="#666666" ForeColor="White" />
</asp:Menu>

</td>
<td colspan="7" valign="top">
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</td>
</tr>
</table>

<asp:SiteMapDataSource ID="SiteMap" runat="server" ShowStartingNode="false" />
</div>
</form>
</body>
</html>



using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class MasterPage : System.Web.UI.MasterPage
{

protected void Page_Load(object sender, EventArgs e)
{
}

protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
{
Response.Write("it worked!");
}
}


Whenever a menu item is clicked... it should display write "it worked!" to the HTML document... but it never does. Am I missing something conceptual here about the order of how events and controls execute methods in ASP.NET 2.0?That should be correct. I do not see anything wrong with the code.
 
Back
Top