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

fire itemclick event

1 Answer 95 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Sigma
Top achievements
Rank 1
Sigma asked on 10 Dec 2012, 10:40 AM
How can i fire itemclick event when the navigateurl property of menuitem is set

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 10 Dec 2012, 10:54 AM
Hi Sigma,

One of the possible solutions is to subscribe to the ItemDataBound / ItemCreated event and set the NavigateUrl property to an empty string as follows.

ASPX:
<telerik:RadMenuItem runat="server" Text="This item will not fire ItemClick event"  NavigateUrl="myPage.aspx">               
</telerik:RadMenuItem>

C#:
protected void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e)     
{         
    e.Item.Attributes["NavigateUrl"] = e.Item.NavigateUrl;         
    e.Item.NavigateUrl = "";     
}          
protected void RadMenu1_ItemClick(object sender, RadMenuEventArgs e)
{         
    //Custom code here                    
    //Navigate         
    Response.Redirect(e.Item.Attributes["NavigateUrl"].ToString());     
}

Please take a look into this documentation for more information.

Hope this helps.

Regards,
Princy.
Archana
Top achievements
Rank 1
commented on 17 May 2021, 07:48 PM | edited

protected void RadMenu1_ItemClick(object sender, RadMenuEventArgs e)
{
//Custom code here
// I have ModalPopupExtender.Show() which is not getting fired
//Navigate
Response.Redirect(e.Item.Attributes["NavigateUrl"].ToString());
}
Vessy
Telerik team
commented on 19 May 2021, 09:22 AM

Hi Archana,

I have already answered your support ticket on the matter, for convenience I am pasting my answer below:

The faced behavior is specific to the AJAX framework page-life cycle and cannot be controlled by us. When the Response.Redirect() the browser navigates to the new page, without rendering the current one again (the Page_PreRender event) thus the ModalPopupExtender is not shown.

This issue is discussed in many places in the web, you can find useful  discussions here:

https://forums.asp.net/t/1762864.aspx 
https://forums.asp.net/t/1510407.aspx 
https://forums.asp.net/t/1528419.aspx 

Tags
Menu
Asked by
Sigma
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or