Contextmenu

6 posts, 1 answers
  1. Christian Pardun
    Christian Pardun avatar
    112 posts
    Member since:
    May 2010

    Posted 15 Feb 2011 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 17 Feb 2011 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Christian Pardun
    Christian Pardun avatar
    112 posts
    Member since:
    May 2010

    Posted 17 Feb 2011 Link to this post

    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
  5. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 18 Feb 2011 Link to this post

    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.
  6. Christian Pardun
    Christian Pardun avatar
    112 posts
    Member since:
    May 2010

    Posted 18 Feb 2011 Link to this post

    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
  7. Christian Pardun
    Christian Pardun avatar
    112 posts
    Member since:
    May 2010

    Posted 18 Feb 2011 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017