Set Attributes of RadMenu

3 posts, 1 answers
  1. Kevin
    Kevin avatar
    265 posts
    Member since:
    Jun 2011

    Posted 15 Apr 2012 Link to this post

    I have a radmenu which i am binding on the code behind, I have been trying to find a way to disgin it as it want it via the html (No luck) and via the designer, but all my items are loaded programmatically.  What I want to do is set the height and width of all my menu items and then center the center height wise.  So for each item the width(200px), height(40px")  and the text vertical centered.  Tried via a css file but the code behind does no get it.

    .Menuitems
        {
            width:200px;
            height:40px;
            cursor:pointer;
            font-size:16;
            text-align:center;
        }


    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
           If Not IsPostBack Then
               'Load the menu system
               sql = "Select intDirectoriteId, strDirectorite from tblDirectorite"
               myDataTable = New DataTable
               myDataTable = getData(sql)
               RadMenu1.DataSource = myDataTable
               RadMenu1.DataTextField = "strDirectorite"
               RadMenu1.DataValueField = "intDirectoriteId"
               RadMenu1.CssClass = "Menuitems"
               RadMenu1.DataBind()
           End If
       End Sub
       Protected Sub RadMenu1_ItemDataBound(sender As Object, e As Telerik.Web.UI.RadMenuEventArgs) Handles RadMenu1.ItemDataBound
           Dim row As DataRowView = CType(e.Item.DataItem, DataRowView)
           e.Item.ToolTip = row("strDirectorite") & " Applications".ToString
       End Sub
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 16 Apr 2012 Link to this post

    Hi Kevin,

    Try the following css to set height and width of RadMenuItems and to align the text in the center.

    CSS:
    <style type="text/css">
     .Menuitems .rmItem
       {
         width:200px !important;
         height:40px !important;
       }
     .Menuitems a.rmLink
       {
         text-align:center !important;
         padding-top:12px !important;
         padding-bottom:12px !important;
       }
     .Menuitems .rmText
       {
         float:none !important;
         font-size:16px !important;
       }
    </style>

    VB:
    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
           If Not IsPostBack Then
               'Load the menu system
               sql = "Select intDirectoriteId, strDirectorite from tblDirectorite"
               myDataTable = New DataTable
               myDataTable = getData(sql)
               RadMenu1.DataSource = myDataTable
               RadMenu1.DataTextField = "strDirectorite"
               RadMenu1.DataValueField = "intDirectoriteId"
               RadMenu1.CssClass = "Menuitems"
               RadMenu1.DataBind()
           End If
    End Sub

    Hope this helps.

    Regards,
    -Shinu.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kevin
    Kevin avatar
    265 posts
    Member since:
    Jun 2011

    Posted 16 Apr 2012 Link to this post

    HI,
    Ok had to take off the applied skin to get it to work correctly, otherwise it did not work so well.  Thanks for the help.
Back to Top