0

I have a RadPanelBar as such...

<telerik:RadPanelBar 
    ID="ResourcesSubMenuRadPanelBar1"
    Width="195px" 
    OnItemClick="RadPanelItemClick"
    ExpandMode="MultipleExpandedItems"    
    OnClientItemClicked="RadPanelClientItemClicked"       
    OnClientLoad="RadPanelBarClientLoad"     
    runat="server" 
    AppendDataBoundItems="true" 
    EnableEmbeddedSkins="false" 
    OnClientItemCollapse="RadPanelClientItemClicked" 
    OnClientItemExpand="RadPanelClientItemClicked">    
</telerik:RadPanelBar>

This all works as expected, except for one little thing. In the code behind, I explicitly set the NavigateUrl property to string.Empty but when an item is clicked, it adds a hash to the url. Obviously, this is because the href attribute has been set to "#" when the control renders the HTML.

I know that I can simply return false from the OnClientItemClicked event, but that will stop the ItemClick event from being fired on the server.

As I say, there is no real error with this code it's just bugging me (and, more importantly, the end users) that there is a # added to the URL.

Does anyone know how to stop this happening?

Dick Lampard
  • 2,256
  • 1
  • 12
  • 7
Simon
  • 2,810
  • 2
  • 18
  • 23
  • I doubt that you can remove the hash symbol unless you use some javascript to strip it manually. But are you sure that leaving the NavigateUrl property of the panelbar blank results in an empty href? – Dick Lampard Jul 28 '11 at 13:51

2 Answers2

1

Try this in your OnClientItemClicking event: eventArgs.set_cancel(true);

Ref: http://www.telerik.com/help/aspnet-ajax/panelbar-onclientitemclicking.html


And, if in case you want the post back to happen, I suppose there is a item.PostBack property (server-side). Set it to true. It should post you back - if the NavigateUrl is empty (or #).

Krishnan
  • 1,464
  • 15
  • 21
  • This doesn't solve my problem as I don't want to stop the default. I need the click to hit the server to fire an event which is handled by the telerik ajax manager. I have resigned myself to having to put up with it. – Simon Aug 08 '11 at 18:51
  • Please check out my updated comment if it resolves your issue. Sorry, didn't know there was a small 'add comment' button here :P – Krishnan Aug 30 '11 at 10:43
0

Compatible in just about every browser, IE9 and up:

Javascript (no jQuery):

stripTelerikHashtag = function () {
    [].forEach.call(
        document.querySelectorAll(".rpLink"),
        function (a) { a.removeAttribute("href") }
    );
};

Javascript (with jQuery):

stripTelerikHashtag = function () { $(".rpLink").removeAttr("href"); };

In your ASP, set OnClientLoad on the RadPanelBar to stripTelerikHashtag.

tuespetre
  • 1,827
  • 2
  • 18
  • 30