MenuItem onclick not firing

2 posts, 0 answers
  1. Rich
    Rich avatar
    31 posts
    Member since:
    May 2011

    Posted 29 Nov 2012 Link to this post

    I have a page where the user can change an address, and when they click Update, I need to run some javascript on the page to ask if they want to change some related addresses, THEN run the code on the server.

    So on the .aspx page I have a javascript function:

     

     

     

    function confirmAddressChange()
    {
        if (document.forms[0].hfAddressChange.value =="")
        
         var res = (confirm('Update Contact Addresses to Match?')==true);
         document.forms[0].hfAddressChange.value = res;    
        }
        return true;
    }

    and on the RadMenuItem I have:  BTW, I've tried onClick, onItemClick, onclick and the one in the code now.

     

    <rad:RadMenuItem ID="rmitmUpdateInfo" runat="server" ImageUrl="~/Images_ABL_Std/Grid/Update.gif"
        Text="Update" Value="update" ToolTip="Accept changes" OnClientItemClicking ="confirmAddressChange()">
    </rad:RadMenuItem>

    What I need to happen is to have the page run the javascript, where I set the value of a hidden field, then run the server code.  At this point it skips the javascript and goes directly to the server code.

    Anyone have a suggestion or answer?

    Thanks.

     

  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 04 Dec 2012 Link to this post

    Hello,

    Please keep in mind that only RadMenu control does provide a OnClientMenuItemClick event. You can try using the approach below in order to achieve the described functionality.
    <telerik:RadMenu ID="RadMenu1" runat="server" OnClientItemClicked="confirmAddressChange">
        <Items>
            <telerik:RadMenuItem ID="rmitmUpdateInfo" runat="server" ImageUrl="~/Images_ABL_Std/Grid/Update.gif"
                Text="Update" Value="update" ToolTip="Accept changes">
            </telerik:RadMenuItem>
        </Items>
    </telerik:RadMenu>


    Regards,
    Boyan Dimitrov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top