SharePoint Create a tabbed view in c#

There are a lot of samples how to create tabbed view for list forms or webparts in SharePoint. Mostly they are build up with javascript, ajax or jquery. Well these technologies are really interesting, but today i am gonna make a short example of creating such tabbed views in c# using asp.net.

The advantages are crystal clear: If you have a form with lots of fields you can group them into tabs and the user

  • see the section important fields
  • does not need to scroll really deep
  • have all fields in the scope of his or her eyes

Ok, let’s start with a simple application page which we add to our project solution. I recently builded the demo based on this post.

In this application page we insert in the aspx file the following code into the placeholder main:



<asp:menu ID="Menu1"

runat="server"
Orientation="Horizontal"
StaticEnableDefaultPopOutImage="False"
OnMenuItemClick="Menu1_MenuItemClick">
<items>
<asp:menuitem ImageUrl="/_layouts/15/images/actionssettings.gif"
Text="Tab 1" Value="0"></asp:menuitem>
<asp:menuitem ImageUrl="/_layouts/15/images/actionssettings.gif"
Text="Tab 2" Value="1"></asp:menuitem>
<asp:menuitem ImageUrl="/_layouts/15/images/actionssettings.gif"
Text="Tab 3" Value="2"></asp:menuitem>
</items>
</asp:menu>


Here we define the menu which appears as tabs. You can choose your own image and your style as well as your text.


<pre id="pre1" lang="html"><asp:multiview ID="MultiView1"
runat="server"
ActiveViewIndex="0" >
<asp:view ID="Tab1" runat="server" >
<table width="600" height="400" cellpadding="0" cellspacing="0">
<tr valign="top">
<td class="TabArea" style="width: 600px">
<br />
<br />
TAB VIEW 1
INSERT YOUR CONENT IN HERE
CHANGE SELECTED IMAGE URL AS NECESSARY
</td>
</tr>
</table>
</asp:view>
<asp:view ID="Tab2" runat="server">
<table width="600px" height="400px" cellpadding="0" cellspacing="0">
<tr valign="top">
<td class="TabArea" style="width: 600px">
<br />
<br />
TAB VIEW 2
INSERT YOUR CONENT IN HERE
CHANGE SELECTED IMAGE URL AS NECESSARY
</td>
</tr>
</table>
</asp:view>
<asp:view ID="Tab3" runat="server">
<table width="600px" height="400px" cellpadding="0" cellspacing="0">
<tr valign="top">
<td class="TabArea" style="width: 600px">
<br />
<br />
TAB VIEW 3
INSERT YOUR CONENT IN HERE
CHANGE SELECTED IMAGE URL AS NECESSARY
</td>
</tr>
</table>
</asp:view>
</asp:multiview></pre>

In this multiview you can add your content which should appear in the tabs.



protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
{

MultiView1.ActiveViewIndex = Int32.Parse(Menu1.SelectedValue);

}


This code snippet acts if you click on one of the tabs. In order to change the tab view.

The result should look like this:

Tabbed

Hope this helps. It won’t win a price for being pretty, but it just shows set it up. The styling and the content is up to you now.

..:: I LIKE SHAREPOINT ::..

The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.

Karsten Pohnke About Karsten Pohnke
He is Consultant for SharePoint Solutions for collaboration, communication and business processes. He provides his customers applications based on standard features as well as development or combining the power of several microsoft tools like Dynamics CRM. In his free time he tries to collect tipps and worthy experience in this blog.

Submit comment

Allowed HTML tags: <a href="http://google.com">google</a> <strong>bold</strong> <em>emphasized</em> <code>code</code> <blockquote>
quote
</blockquote>

Please fill in the captcha: * Time limit is exhausted. Please reload CAPTCHA.