I've looked at about 5 Questions here on SOF and haven't really found a useful answer for this. How am I supposed to invoke my javascript functions from client-side events in my .ascx controls? Here is my .ascx file.. what most the answers have led me to:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="UIMenu.ascx.cs" Inherits="controls_UIMenu" %>
<script language="javascript" type="text/javascript">
function insetItem(myMenu)
{
myMenu.setAttribute("class", "myClass");
}
</script>
<asp:Menu ID="Menu1" runat="server" Font-Bold="True" Font-Size="Large" Height="50px"
Orientation="Horizontal" Target="_self" StaticMenuItemStyle-HorizontalPadding="10px"
OnMenuItemClick="insetItem(this)" StaticMenuItemStyle-BorderStyle="outset">
<Items>
<asp:MenuItem NavigateUrl="~/Home.aspx" Target="_self" Text="Home" Value="Home"></asp:MenuItem>
<asp:MenuItem NavigateUrl="~/Loaner.aspx" Target="_self" Text="New" Value="New"></asp:MenuItem>
</Items>
</asp:Menu>
I'm getting different errors when doing it this way. ".....ascx does not contain a definition for "insetItem"", and my other pages that use this file don't recognize it anymore. When I try to put the js on the actual .aspx pages that will be using it, I get the same no definition error.
I just started learning jscript, still pretty noob. I'm trying to make it so when the user down clicks a menu item, I want that item's borderstyle to change to "inset". I'm not sure how to change that attribute for the specific item that gets clicked either in javascript >_< but that's another question. If anyone could lead me the right way in doing this too, that'd be amazing. Thanks!