Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
415
Clicking on DataMenuItem causes unwanted page navigation in Firefox and Chrome
posted

I have a WebDataMenu and it's items all trigger a server side event that does not require navigation to another page.

In IE, the menu works fine.

In Firefox and Chrome, the browser attempts to navigate to the NavigateUrl property of the menu item, which I have left blank. 

This results in a 404 error since the destination url is not valid.  

Is there a way to trigger my server side code without having the browser try to navigate away?

Here is my aspx and javascript code:

<ig:WebDataMenu runat="server" ID="wdmAddToRequirement" GroupSettings-Orientation="Vertical"
Font-Bold="false" BorderStyle="None" OnItemClick="wdmAddToRequirement_ItemClick">
<AutoPostBackFlags ItemClick="On" />
<ClientEvents ItemUnhovered="wdmAdd_ItemUnhovered" ItemClick="wdmAdd_ItemClick" />
<Items>
<ig:DataMenuItem Text="Add" Value="Add" Target="#">
<Items>
<ig:DataMenuItem Text="Requirement" Value="Requirement" Target="#" />
<ig:DataMenuItem Text="Global Element" Value="GlobalElement" Target="#" />
<ig:DataMenuItem Text="Local Element" Value="LocalElement" Target="#" />
</Items>
</ig:DataMenuItem>
</Items>
</ig:WebDataMenu>

// prevent goofy page scrolling issue
function wdmAdd_ItemUnhovered(sender, eventArgs) {
sender.__lastFocusedElement = null;
}

// don't post back if clicking on top level of menu
function wdmAdd_ItemClick(sender, eventArgs) {
eventArgs.set_cancel(eventArgs.getItem().hasChildren());
}

And here is the C# code for my server event:

protected void wdmAdToRequirement_ItemClick(object sender, DataMenuItemEventArgs e)
{
DataMenuItem item = e.Item;
string itemValue = item.Value;
if (!itemValue.Equals("Add"))
{
Guid commandArgument = new Guid(item.Key);
switch (itemValue)
{
case "Requirement":
ShowAddRequirementModal(commandArgument);
break;
case "GlobalElement":
ShowAddElementModal(commandArgument);
break;
case "LocalElement":
ShowAddLocalElementModalForInsert(commandArgument);
break;
default:
break;
}
}
}

Any help is appreciated.  Thanks!

 

Parents
No Data
Reply
  • 17559
    Verified Answer
    posted

    Hello jmakuch ,

     

    If you are using the  AntiXSSLibrary.dll it will change the encoding of the “#” symbol in the URL. This makes the control to redirect to page that doesn’t exist. In order to workaround this you can modify the client side event for ItemClick like this:

            function wdmAddToRequirement_ItemClick(sender, eventArgs) {

                eventArgs.getItem().get_element().children[0].href = "#"

       // eventArgs.set_cancel(eventArgs.getItem().hasChildren());

    }

     

    Please let me know if this helps.

Children