This code example comes directly from MSDN at
My question is, say, I wanted to add some sort of confirmation prompt, like a javascript confirm() dialog for when the user selects the "Drama" option.
In other words, I before the page writes "you chose Drama" I want to challenge the user with "are you sure you want to choose drama?".
Can this be done?
My question is, say, I wanted to add some sort of confirmation prompt, like a javascript confirm() dialog for when the user selects the "Drama" option.
In other words, I before the page writes "you chose Drama" I want to challenge the user with "are you sure you want to choose drama?".
Can this be done?
Code:
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<script runat="server">
Sub NavigationMenu_MenuItemClick(ByVal sender As Object, ByVal e As MenuEventArgs)
' Display the text of the menu item selected by the user.
Message.Text = "You selected " & _
e.Item.Text & "."
End Sub
</script>
<html >
<head id="Head1" runat="server">
<title>Menu MenuItemClick Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Menu MenuItemClick Example</h3>
<asp:menu id="NavigationMenu"
staticdisplaylevels="2"
staticsubmenuindent="10"
orientation="Vertical"
onmenuitemclick="NavigationMenu_MenuItemClick"
runat="server">
<items>
<asp:menuitem text="Home"
tooltip="Home">
<asp:menuitem text="Music"
tooltip="Music">
<asp:menuitem text="Classical"
tooltip="Classical"/>
<asp:menuitem text="Rock"
tooltip="Rock"/>
<asp:menuitem text="Jazz"
tooltip="Jazz"/>
</asp:menuitem>
<asp:menuitem text="Movies"
tooltip="Movies">
<asp:menuitem text="Action"
tooltip="Action"/>
<asp:menuitem text="Drama"
tooltip="Drama"/>
<asp:menuitem text="Musical"
tooltip="Musical"/>
</asp:menuitem>
</asp:menuitem>
</items>
</asp:menu>
<hr/>
<asp:label id="Message"
runat="server"/>
</form>
</body>
</html>