SharePoint custom menu bar

Source: Internet
Author: User

The UI of sharepoint2010 has been greatly improved, and an important embodiment is ribbon. However, some people do not like this operation, so I think of the 2007 toolbar.

In the toolbar, you can create, delete, and switch projects.

The effect is as follows:

1: Toolbar

You must first place the new or deleted project button in the container. A custom control is provided in Sharepoint, which is stored in c: \ Program Files \ common files \ microsoft shared \ Web Server Extensions \ 14 \ template \ controltemplates/toolbar. ascx. If you want to be lazy, this control has already completed the style and can be used directly. Of course, you can also modify the style on your own. The toolbar. ascxCodeAs follows:

<% @ Control Language = "C #" inherits = "Microsoft. sharepoint. webcontrols. toolbar, Microsoft. sharepoint, version = 14.0.0.0, culture = neutral, publickeytoken = secret "autoeventwireup =" false "compilationmode =" always "%> <% @ register tagprefix =" wssawc "namespace =" Microsoft. sharepoint. webcontrols "assembly =" Microsoft. sharepoint, version = 14.0.0.0, culture = neutral, publickeytoken = 71e9bce111e9429c "%> <% @ register tagprefix =" SharePoint "namespace =" Microsoft. sharepoint. webcontrols "assembly =" Microsoft. sharepoint, version = 14.0.0.0, culture = neutral, publickeytoken = 71e9bce111e9429c "%> <Table class =" <% = cssclass %> "cellpadding =" 2 "cellspacing =" 0 "border =" 0 "id =" <% = clientid %> "width =" 100% "> <tr> <% -- buttons on the left -- %> <wssawc: repeatedcontrols id = "rptcontrols" runat = "server"> 

If you want to modify styles, we recommend that you rewrite these defined styles in your own style sheet.

We reference this Toolbar Control:

 
<% @ Register src = "/_ controltemplates/toolbar. ascx" tagprefix = "ylsoft" tagname = "toolbar" %>

 

 
<Ylsoft: toolbar id = "tbar" runat = "server"> <template_buttons> </template_buttons> <template_rightbuttons> </ylsoft: toolbar>

 

Place the left button set and the rightmost button set on template_buttons and template_rightbuttons respectively. Generally, all views are placed on the right. You can drag the control to it. To make it more beautiful, several SharePoint controls are used here.

Menu:

 
<SharePoint: menu id = "menunew" runat = "server" templateid = "menutemplatenew" text = "<% $ resources: WSS, percent %> "menuformat =" arrowalwaysvisible "menualignment =" Left "percent =" MS-menubuttonactivehover "percent =" MS-menubuttoninactivehover "accesskey =" <% $ resources: WSS, tb_newmenu_ak %> "/>

The resource file <% $ resources: WSS, multipages_new_menu_text %> is used to call resources of WSS. resx and whose key is multipages_new_menu_text. Put the resource file under the directory. The value of multipages_new_menu_text is new (new ).

<Data name = "multipages_new_menu_text"> <value> New </value> </data>

What sub-menus does menunew have in the West? There is an important property: templateid. Templateid indicates the template from which the sub-menu is obtained. Here I specify menutemplatenew. Let's take a look at its definition:

 
<SharePoint: featuremenutemplate id = "menutemplatenew" largeiconmode = "true" runat = "server" groupid = "newmenu"> <SharePoint: newmenu menualignment = "default" id = "newmenu" runat = "server"> </SharePoint: newmenu> </SharePoint: featuremenutemplate>

I placed a new menu under the menu template of menutemplatenew. View results

Newmenu is the new content type to obtain the current list. You can also add new content by encoding. This seems to require inheritance. This newmenu has been rewritten before.

Delete project menu:

<Ylsoft: toolbarbutton id = "btndel" onclientclick = "getsels (); Return false;" runat = "server" text = "<% $ resources: WSS, setanon_deleteitems_display %> "> </ylsoft: toolbarbutton>

The toolbarbutton styles are all Sharepoint, so it looks pleasing to the eye. It is a bit disgusting to put the button directly.

The UI code is as follows:

<% @ Assembly name = "$ Sharepoint. project. assemblyfullname $ "%> <% @ Assembly name =" Microsoft. web. commandui, version = 14.0.0.0, culture = neutral, publickeytoken = 71e9bce111e9429c "%> <% @ register tagprefix =" SharePoint "namespace =" Microsoft. sharepoint. webcontrols "assembly =" Microsoft. sharepoint, version = 14.0.0.0, culture = neutral, publickeytoken = 71e9bce111e9429c "%> <% @ register tagprefix =" utilities "namespace = "Microsoft. sharepoint. utilities "assembly =" Microsoft. sharepoint, version = 14.0.0.0, culture = neutral, publickeytoken = 71e9bce111e9429c "%> <% @ register tagprefix =" asp "namespace =" system. web. ui "assembly =" system. web. extensions, version = 3.5.0.0, culture = neutral, publickeytoken = 31bf3856ad364e35 "%> <% @ import namespace =" Microsoft. sharePoint "%> <% @ register tagprefix =" webpartpages "namespace =" Microsoft. sh Arepoint. webpartpages "assembly =" Microsoft. sharepoint, version = 14.0.0.0, culture = neutral, publickeytoken = 71e9bce111e9429c "%> <% @ Control Language =" C # "autoeventwireup =" true "codebehind =" listtoolbarusercontrol. ascx. CS "inherits =" ylsoft. features. webparts. listtoolbar. listtoolbarusercontrol "%> <% @ register src ="/_ controltemplates/toolbar. ascx "tagprefix =" ylsoft "tagname =" toolbar "%> <% @ register tagpre Fix = "ylsoft" tagname = "toolbarbutton" src = "~ /_ Controltemplates/toolbarbutton. ascx "%> <! -- Templates --> <SharePoint: featuremenutemplate id = "menutemplatenew" largeiconmode = "true" runat = "server" groupid = "newmenu"> <SharePoint: newmenu menualignment = "default" id = "newmenu" runat = "server"> </SharePoint: newmenu> </SharePoint: featuremenutemplate> <SharePoint: menutemplate runat = "server" id = "menutemplateview"> <SharePoint: viewselectormenu id = "viewselector" runat = "server"> </SharePoint: viewsele Ctormenu> </SharePoint: menutemplate> <! -- End template --> <ylsoft: toolbar id = "tbar" runat = "server"> <template_buttons> <SharePoint: menu id = "menunew" runat = "server" templateid = "menutemplatenew" text = "<% $ resources: WSS, percent %> "menuformat =" arrowalwaysvisible "menualignment =" Left "percent =" MS-menubuttonactivehover "percent =" MS-menubuttoninactivehover "accesskey =" <% $ resources: WSS, tb_newmenu_ak %> "/> <ylsoft: toolbarbutton id =" btndel "onclientclick =" getsels (); Return false; "runat =" server "text =" <% $ resources: WSS, setanon_deleteitems_display %> "> </ylsoft: toolbarbutton> </template_buttons> <template_rightbuttons> <asp: placeholder id = "placeholder1" runat = "server"> <Table border = "0" cellpadding = "0" cellspacing = "0" style = 'margin-right: 4px '> <tr> <TD nowrap = "nowrap" class = "MS-toolbar" id = "toppagingcell"> </TD> <TD nowrap = "nowrap" >& #160; </TD> <TD nowrap = "nowrap" class = "MS-listheaderlabel"> <SharePoint: encodedliteral id = "encodedliteral1" runat = "server" text = "<% $ resources: WSS, view_selector_view %>" encodemethod = 'htmlencode'/>&# 160; </TD> <TD nowrap = "nowrap" class = "MS-viewselector" onmouseover = "this. classname = 'Ms-viewselectorhover '"onmouseout =" this. classname = 'Ms-viewselector '"id =" onetpeopleviewselector "> <SharePoint: menu id = "menuviewselector" runat = "server" templateid = "menutemplateview" text = "<% $ resources: WSS, authorization %> "menuformat =" arrowalwaysvisible "menualignment =" right "placement =" onetpeopleviewselector "placement =" MS-viewselectorhover "placement =" MS-viewselector "accesskey =" <% $ Resources: WSS, tb_viewselector_ak %> "/> </TD> </tr> </table> </ASP: placeholder> </template_rightbuttons> </ylsoft: toolbar>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.