Tips, tricks and frequently asked questions for TMS ASP.NET components

MainMenu, SideMenu

  • How to programmatically add a menu

    This code snippet adds a root menu to the MainMenu with a submenu with one menu item:

      MenuItem mi, mis;
      mi = new MenuItem();
      mi.Caption = "Root item";
      mis = new MenuItem();
      mis.Caption = "Sub Item";

      Dim mi As TMSWebControls.MenuItem
      Dim mis As TMSWebControls.MenuItem
      mi = New TMSWebControls.MenuItem
      mi.Caption = "Root Item"
      mis = New TMSWebControls.MenuItem
      mis.Caption = "Sub Item"

  • How to navigate to another page from client-script

    In the client-script of the menu item put :

        window.location.href = ""


  • How to programmatically add a HTML Editor

    This code snippet adds 5 lines to a HTML Editor:

     int i;
     for (i = 0; i < 5; i++)
       ListItem li;
       int j = i + 1;
       li = new ListItem("Line "+j.ToString(),"");

  • How to programmatically get the text of a HTML Editor

    This code snippet gets the text from the HTML Editor as a single string:

      string txt = string.Empty;
      foreach(ListItem it in HtmlEdit1.Lines)
        txt += it.Text;

  • Project settings to set for use of a HTML Editor without request validation

    In ASP.NET 1.1 request validation will cause an error when text with HTML tags is sent back to the server. To solve this, add in the file Web.Config of your project following line:

    <pages validateRequest="false" />


  • How to add combobox items to a combobox column in AdvWebGrid programmatically

    This code snippet adds the value "New item" to the combobox in the 2nd column of the AdvWebGrid:

    ListItem lt = new ListItem("New item");
    Column col = (Column) AdvWebGrid1.Columns[1];

  • How to programmatically insert a new column with centered alignment in the grid

    The code creates a new column, sets its alignment property and adds it to the grid:

    TMSWebControls.Column col;
    col = new TMSWebControls.Column();
    col.Alignment = Column.Aligning.Center;


  • How to change OutlookBar items programmatically

    This code snippet shows how to change a panel's caption and item's caption programmatically:

    OutlookPanel op;
    OutlookItem oi;
    op = (OutlookPanel)Outlookbar1.Panels[0];
    op.Caption = "Panel Caption";
    oi = (OutlookItem)op.Items[0];
    oi.Caption = "Item Caption";