I have an RadAjaxPanel that has a panel in it that I dynamically create Image buttons in for cached searches. This works fine. I want to add a context menu to each button so I can give the user a way to remove the cached search. So if left-click the button it will redirect them to open the seach. When they Right-click I want the context menu to appear. Not sure the best way to do this on the server and attach individually to dynamic buttons.
Any samples show something like this?
11 Answers, 1 is accepted
0
Hello,
I suggest you create the context menu in the aspx page like this:
and then when you create the image buttons, you can set them as targets of the menu:
Hope this helps.
Greetings,
Yana
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
I suggest you create the context menu in the aspx page like this:
<telerik:RadContextMenu ID="contextMenu1" runat="server"> |
<Items> |
<telerik:RadMenuItem Text="delete" /> |
</Items> |
</telerik:RadContextMenu> |
and then when you create the image buttons, you can set them as targets of the menu:
ImageButton btn = new ImageButton(); |
btn.Text = "btn text"; |
btn.ID = "btnID"; |
ContextMenuControlTarget target = new ContextMenuControlTarget(); |
target.ControlID = "btnID"; |
contextMenu1.Targets.Add(target); |
Hope this helps.
Greetings,
Yana
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

jgig
Top achievements
Rank 1
answered on 10 Sep 2008, 04:00 PM
OK I did what you said but I never see the menu. Haven't used this control before and there isn't alot of content to read about it.
How do I assign it to Right Click show the menu?
Since I have '1 to many' ImageButtons I am assigning this to... can I add a whats the correct way to kick off a shared function to process the delete and to tell the buttons appart?
Right now I am assigning this and this is unique:
target.ControlID = string.Format("SearchButton{0}", sw.ID);
How do I assign it to Right Click show the menu?
Since I have '1 to many' ImageButtons I am assigning this to... can I add a whats the correct way to kick off a shared function to process the delete and to tell the buttons appart?
Right now I am assigning this and this is unique:
target.ControlID = string.Format("SearchButton{0}", sw.ID);
0

jgig
Top achievements
Rank 1
answered on 10 Sep 2008, 09:15 PM
Oops, I do see the menu now. I have also wired up the ItemClick
my next question is how from the ItemClick event on the server can I get which menu was clicked? I need to make it unique sot that I know which menu (target) fired off the event so I can perform a function.
I am using the ContextMenuControlTarget like you suggested.
thanks
my next question is how from the ItemClick event on the server can I get which menu was clicked? I need to make it unique sot that I know which menu (target) fired off the event so I can perform a function.
I am using the ContextMenuControlTarget like you suggested.
thanks
0
Hello,
You have to subscribe to OnClientShowing event of the context menu and set a custom attribute to the id of its target button. In this way in Atomics event handler you can get the target of the opened menu. I prepared a small demo project which shows this approach. Please download the attached file and give it a try.
Kind regards,
Yana
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
You have to subscribe to OnClientShowing event of the context menu and set a custom attribute to the id of its target button. In this way in Atomics event handler you can get the target of the opened menu. I prepared a small demo project which shows this approach. Please download the attached file and give it a try.
Kind regards,
Yana
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

jgig
Top achievements
Rank 1
answered on 12 Sep 2008, 05:21 PM
thank you for the sample proj. I am going to try it asap. Another small issue is that I am putting buttons in my ajaxpanel. They no longer work. When I click them it just Updates the RadAjaxPanel and my event is lost. The UpdatePanel has a ChildrenasTriggers property...I can't find a similar property on the RadAjaxPanel. Anything special I need to do or set for this?
0
Accepted
Hello,
In the project I attached in my previous post I use RadAjaxPanel and it works without a problem. Could you please check what is different in your case?
If you still experience this issue, open a support ticket and send us your project so we can test it locally. Thanks
Regards,
Yana
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
In the project I attached in my previous post I use RadAjaxPanel and it works without a problem. Could you please check what is different in your case?
If you still experience this issue, open a support ticket and send us your project so we can test it locally. Thanks
Regards,
Yana
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

jgig
Top achievements
Rank 1
answered on 15 Oct 2008, 08:49 PM
sorry for the late reply. This project helped me achieve the desired effect. Assigning dynamic attributes to the button and getting access to them through the javascript of the target element is just what I needed.
0

jgig
Top achievements
Rank 1
answered on 04 Dec 2008, 08:14 PM
I updated to the latest version of Rad AJAX Controls "Telerik.Web.UI, Version=2008.3.1105.35". Now it doesnt work again (only works in IE) for FF and Safari
it definately did before, the attributes are set in the HTML. but the MenuID and the MenuType from the attributes are NULL. Do I need to do this differently for the attributes?
protected void rcmSubMenu_ItemClick(object sender, RadMenuEventArgs e) |
{ |
string MenuID = rcmSubMenu.Items[0].Attributes["MenuID"]; |
string MenuType = rcmSubMenu.Items[0].Attributes["MenuType"]; |
if (MenuID != null && MenuType != null && MenuID != string.Empty && MenuType != string.Empty) |
{ |
if (MenuType == "Other")//ALL search windows - except PNR |
{ |
SearchList.GetSearchList().Remove(int.Parse(MenuID)); |
} |
else//PNR |
{ |
PNRList.Current.Remove(int.Parse(MenuID)); |
} |
LoadSubMenu();//Reload Sub Menu |
} |
} |
0

jgig
Top achievements
Rank 1
answered on 04 Dec 2008, 09:53 PM
OK I fixed my problem (I dont think it was tested in the other browsers after all)
the ZIP file had javascript code to get the id and I assumed it was ok to get custom attributes like that. Worked in IE so I think I just didnt even notice it. Oops
Changed
attributes.setAttribute("MenuType", targetElement.MenuType);
to
attributes.setAttribute("MenuType", targetElement.getAttribute("MenuType"));
actually surprised IE worked like that
0

Stone Heart
Top achievements
Rank 1
answered on 23 Mar 2010, 04:08 PM
Hi.
How to add target element in client side ?
thanks.
How to add target element in client side ?
thanks.
0
Hi Stone Heart,
You can use the addTargetElement method of the RadContextMenu client object.
Kind regards,
Veskoni
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
You can use the addTargetElement method of the RadContextMenu client object.
Kind regards,
Veskoni
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.