This is a migrated thread and some comments may be shown as answers.

RadMenuItem Prevent Click Postback

1 Answer 109 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Mahesh Babu
Top achievements
Rank 1
Mahesh Babu asked on 06 Aug 2009, 05:19 AM
Hi,

I have a RadContextMenu to which I am adding RadMenuItem's. Now for a particular RadMenuItem, I dont want to do a postback.

How can achieve this functionality???


Thanks,
Mahesh

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 06 Aug 2009, 06:18 AM
Hi Mahesh,

Attach OnClientItemClicking event to RadContextMenu and check for the clicked item text to cancel the event which will prevent the postback. See the example shown below.

ASPX:
 
<telerik:RadContextMenu ID="RadContextMenu1" runat="server" OnClientItemClicking="OnClientItemClicking" OnItemClick="RadContextMenu1_ItemClick">  
    <Items>  
      . . .  
    </Items>  
    <Targets>  
      . . . 
    </Targets>  
</telerik:RadContextMenu>  

JavaScript:
 
<script type="text/javascript">  
function OnClientItemClicking(sender , args)  
{  
    if(args.get_item().get_text() == "Item2")  
    { 
        args.set_cancel(true);  
        sender.hide();          
    }  
}  
</script>  

-Shinu.
Tags
Menu
Asked by
Mahesh Babu
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or