telerik:RadMenu XmlDataSource hyperlink

11 posts, 1 answers
  1. daniel liu
    daniel liu avatar
    29 posts
    Member since:
    Oct 2009

    Posted 16 Dec 2009 Link to this post

    Hi,

    Would you please provide sample code to enable hyperlink for telerik:RadMenu + XmlDataSource ?

    Thanks

    daniel
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 17 Dec 2009 Link to this post

    Hi Daniel,

    When binding to an XmlDataSource, RadMenu creates the menu item hierarchy automatically. Checkout the following documentation that shows how to bind RadMenu with XmlDataSource.
    Binding to Hierarchical DataSource Components

    -Shinu.
  3. daniel liu
    daniel liu avatar
    29 posts
    Member since:
    Oct 2009

    Posted 17 Dec 2009 Link to this post

    Thanks, it works fine.

    Is it anyway to manage the authorization from xml or c# code? like some menu items will auto-hide if some login users do not in a Admin role?

    thanks

    daniel
  4. daniel liu
    daniel liu avatar
    29 posts
    Member since:
    Oct 2009

    Posted 22 Dec 2009 Link to this post

    Hi,
    Is it anyway to manage the menu authorization from xml or c# code?

    like some menu items will auto-hide if some login users do not in a Admin role?

    thanks

    daniel

  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 23 Dec 2009 Link to this post

    Hello Daniel,

    You can set visibility of RadMenuItems in ItemDataBound event after checking the user logged in mode.

    CS:
     
        protected void RadMenu1_ItemDataBound(object sender, Telerik.Web.UI.RadMenuEventArgs e) 
        { 
            if (userMode)// Check for the user mode 
            { 
                if (e.Item.Text == "ANATR"
                { 
                    e.Item.Visible = false
                } 
            } 
        } 

    -Shinu.
  6. daniel liu
    daniel liu avatar
    29 posts
    Member since:
    Oct 2009

    Posted 23 Dec 2009 Link to this post

    Thanks for reply.

    Could you show how to manage the menuitem visibility by using AccessKey in C# code?

       <Item Text="Administrator Menu" AccessKey="Admin" >

    Thanks a lot.

    daniel


  7. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 25 Dec 2009 Link to this post

    Hello daniel,

    You can still use Shinu's suggestion and check the items' AccessKey value in ItemDataBound:
    protected void RadMenu1_ItemDataBound(object sender, Telerik.Web.UI.RadMenuEventArgs e)  
       {  
           if (userMode)// Check for the user mode  
           {  
               if (e.Item.AccessKey== "Admin")  
               {  
                   e.Item.Visible = true;  
               }  
           }  
       }  


    Kind regards,
    Peter
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  8. daniel liu
    daniel liu avatar
    29 posts
    Member since:
    Oct 2009

    Posted 04 Jan 2010 Link to this post

    I tried it in RadMenu1_ItemDataBound event, but

    e.Item.AccessKey always return empty string, and e.Item.Text returns correct value.

    Did I miss anything?

    Thanks

    daniel
  9. daniel liu
    daniel liu avatar
    29 posts
    Member since:
    Oct 2009

    Posted 05 Jan 2010 Link to this post

    Hi,

    did not get your reply yet.

    Would you help to find out why e.Item.AccessKey always return empty string in RadMenu1_ItemDataBound event?

    Thanks

    daniel
  10. Answer
    Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 07 Jan 2010 Link to this post

    Hi daniel liu,

    Actually, e.Item.AccessKey corresponds to the AccessKey property of the RadMenuItem class which is used to assign an access key to the menu item.
    In your case you need to do the following:

    void RadMenu1_ItemDataBound(object sender, Telerik.Web.UI.RadMenuEventArgs e)
    {
        XmlElement sourceData = (e.Item.DataItem as System.Xml.XmlElement);
        if (sourceData.Attributes["AccessKey"] != null && sourceData.Attributes["AccessKey"].Value == "admin")
        {
            //admin AccessKey
        }
    }

    Hope this helps.

    All the best,
    Veskoni
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  11. daniel liu
    daniel liu avatar
    29 posts
    Member since:
    Oct 2009

    Posted 12 Jan 2010 Link to this post

    thanks, it works.
Back to Top