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

Contextmenu

5 Answers 78 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 15 Feb 2011, 01:35 PM
Dear Telerik-Support

I want to use a RadContextMenu on a RadRotator. So if the user right click on a RotatorItem the a RadContextMenu should be shown.

Can you give me an exapmle for this scenario?

Kind Regargs,
Christian

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 17 Feb 2011, 10:03 AM
Hello Christian,

You can set  each item in the RadRotator as the TargetControl for the.RadContextMenu. Here is the sample code for achieving the same.

aspx:
<telerik:RadRotator ID="RadRotator1" runat="server" RotatorType="Buttons" Height="100px"
            Width="200px" OnClientLoad="OnClientLoad" OnItemDataBound="RadRotator1_ItemDataBound">
      <Items>
           <telerik:RadRotatorItem>
           <ItemTemplate>
               <img src="../Images/ANATR.jpg" alt="yellow flowers" />
           </ItemTemplate>
           </telerik:RadRotatorItem>
           <telerik:RadRotatorItem>
            <ItemTemplate>
                <img src="../Images/ANATR.jpg" alt="yellow flowers" />
            </ItemTemplate>
           </telerik:RadRotatorItem>
           <telerik:RadRotatorItem>
             <ItemTemplate>
              <img src="../Images/ANATR.jpg" alt="yellow flowers" />
              </ItemTemplate>
          </telerik:RadRotatorItem>
          <telerik:RadRotatorItem>
              <ItemTemplate>
               <img src="../Images/ANATR.jpg" alt="yellow flowers" />
       </ItemTemplate>
        </telerik:RadRotatorItem>
      </Items>
</telerik:RadRotator>
<telerik:RadContextMenu ID="RadContextMenu1" runat="server">
   <Items>
       <telerik:RadMenuItem Text="Preview">
       </telerik:RadMenuItem>
   </Items>
</telerik:RadContextMenu>

C#:
protected void Page_Load(object sender, EventArgs e)
  {
      foreach (RadRotatorItem item in RadRotator1.Items)
      {
          ContextMenuControlTarget target = new ContextMenuControlTarget();
          target.ControlID = item.ClientID;
          RadContextMenu1.Targets.Add(target);
      }
  }

Thanks,
Shinu.
0
Christian
Top achievements
Rank 1
answered on 17 Feb 2011, 12:35 PM
Hey Shinu,

that's a good idea. But if I right click on a RadRotatorItem nothing happens. So something must be implement on client side (javascript) or?

Thanks for your support on this issue!

Kind regards
Christian
0
Accepted
Shinu
Top achievements
Rank 2
answered on 18 Feb 2011, 11:30 AM
Hello Christian,
You need to attach events to handle the RadContextMenuItem click. and handle the event from there.
aspx:
<telerik:RadContextMenu ID="RadContextMenu1" runat="server"
          OnClientItemClicking="OnClientItemClicking"
          onitemclick="RadContextMenu1_ItemClick">
           . . . . . . . . . . . . .

Javascript:
function OnClientItemClicking(sender, args)
  {
 //your code here
  }

Here you can find more on handling the clicked item form client side and server side.
OnClientItemClicking
ItemClick

Thanks,
Shinu.
0
Christian
Top achievements
Rank 1
answered on 18 Feb 2011, 01:32 PM
Dear Shinu,

thanks again!

We missunderstood us on this point. I mean something different. What must I implemented, to archive that the RadContetMenu is shown if I right click on a RadRoatatorItem. But I noticed that this behaviour is archive by adding targets to the RadContextMenu. So far its great.

But unfortunatly if a ajax postback is occured the RadConxtstMenu isn't shown again when I right click on another RadRotatorItem after the ajax postback. If I processed a full postback the RadContextMenu is back again.

I try to maintain the RadContextMenu by adding the targets on every kind of postback again, but it doesn't helps!

Whats the problem here?

Thanks for help, again! :)

Greetings,
Christian
0
Christian
Top achievements
Rank 1
answered on 18 Feb 2011, 01:52 PM
Dear Shinu,

I found my problem. I forgot to maintain the ajax settings on the RadAjaxManager. So everthing works fine for me!

Thanks a lot and enjoy your weekend!

Greetings,
Christian
Tags
Rotator
Asked by
Christian
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Christian
Top achievements
Rank 1
Share this question
or