Torpedo
Torpedo

Reputation: 139

How to avoid Menu items having navigate Url property with #

I'm binding some items to a menu. Assuming, my site address is "www.abc.com/Dev", the menu items automatically get the navigateUrl of "www.abc.com/Dev/#".

Now, these menu items when clicked open some applications like 'Notepad'.

Because of the navigateUrl property of these menu items, if I right click on the items, it gives me a context menu and if I click on 'Open in New Window', it takes me back to my original site.

Ideally, this is the wrong behaviour. Is there some way I can prevent the setting of the navigateUrl? I tried making:

menuItem.NavigateUrl = null

But once the menuItems are initialized, they have the navigateUrl property set with #.

Is there any way I can prevent this.

Upvotes: 1

Views: 3203

Answers (2)

Jigar Pandya
Jigar Pandya

Reputation: 5987

Well do the following in that case,

put menuItem.NavigateUrl = string.Empty or menuItem.NavigateUrl = "" which will produce "#"

On the top of that add menuItem.attributes.add("onclick","TrackRightClickAndReturnFalse")

This way you can have "#" but you can prevent the right click button click on it...

See this How to disable right-click context-menu in javascript to see how you can get idea on how to disable right click.

I hope you understand my concept.

Upvotes: 1

Akhil
Akhil

Reputation: 7610

menuItem.NavigateUrl = "javascript: void(0);";

Upvotes: 2

Related Questions