Create custom web-part page with OOTB page layout using CSOM (Javascript)

Hi,
I need to create a custom webpart page with a OOTB page layout (eg. Header 3 column footer) using JSOM.
I found a link to do this using CSOM: http://spdevlab.com/2013/03/28/creating-wiki-web-part-and-publishing-pages-via-csom-in-sharepoint-2010/
But here i have to copy the page template from 15 hive and store it in a resource file and I am also getting error as "The request message is too big" and to fix this I need to run a powershell script but I need the code to run in SharePoint online
also.
Isn't there a simpler piece of code in which I can enter the name of the page layout(OOTB/Custom) while creating a page in JSOM as we have in SSOM?
Thanks for the help
sunny

Hi,
According to your post, my understanding is that you want to create a custom web part page layout template.
There are some articles about how to create the custom web part page layout template, you can refer to them.
http://www.manageprojectsonsharepoint.com/blog/2011/03/14/creating-your-own-web-part-page-layout-template/
http://sandeeppawar.blogspot.com/2012/06/create-custom-web-part-page-template.html
http://doitwithsharepoint.blogspot.com/2011/08/create-web-part-pages-with-custom.html
Thanks & Regards,
Jason
Jason Guo
TechNet Community Support

Similar Messages

  • SharePoint 2013 and IE 11 issue - While creating a Web Part Page and Editing Web Part Properties

    I tried to edit a Web Part in SharePoint 2013 using IE 11 but I did not see the Edit Eeb Part dropdown menu at the top-right corner of the web part. Then I tried to create a Web Part page and I get the following error.
    Cannot create a Web Part Page with the current browser. Browsers that support the creation of Web Part Pages include Microsoft Internet Explorer 7.0 or later, Mozilla Firefox 3.0 or later, and Apple Safari 3.0 or later
    Strange !!! My web browser is IE 11.
    I tried the above two tasks in Google Chrome and worked fine.
    Solution:
    I added the site url to local intranet zone in IE 11 and I am now able to add Web Part Page and Edit Web Part in IE 11.
    imd.net

    Hi - One more solution is to add SharePoint site to compatibility group:
    http://blog.fpweb.net/sharepoint-internet-explorer-compatibility-issues-with-video/#.VAaZSPmSyy4
    -prs

  • How to enable a custom web part class file to be refreshed at regular interval of time, without affecting the entire page where its placed.

    Hi,
    I am calling a web service in the web part class file where it gets the data. I need to call the service at regular intervals of time which is in the web part, is there a way to get the web part refreshed automatically at certain intervals of time.
    Rayudu

    You can use Ajax for automatic refreshing.
    Add a timer control into an Ajax Update panel within your custom web part and execute your code to refresh the field values within the Timer_Tick() event.
    You can also control the timer interval to 10 minutes or so using the Timer.Interval property.
    This will always enable your page to remain with only the web parts getting refreshed.
    I just found
    a blog post which describes this in detail with screenshots.

  • 2013 Custom Web Parts in Page Layouts not showing for users

    Custom Web Parts in Page Layouts not showing for users
    I have created a master page in the root site collection for a subsite I am developing. I created content types and custom page layouts for the pages within the subsite.
    I used the snippet tool in the design manager to create web parts and page field markup which I copied into the custom layout HTML pages in the root site collection. For instance I have an image viewer web part that I place there to serve as a section title.
    The problem is that I can see all these customer layout page parts no problem but my users cannot. This leads me to believe its permissions, I am site owner of both the subsite and root site collection.
    The users that cannot see the web parts are site members of the site and restricted read users on the root site collection (where the layouts are stored).
    What gives I'm finding it hard to understand why a snipet generated web part wouldn't show in all pages created from that layout page.
    Any help would be appreciated, Havent found anything on this issue online. weird.

    It is a permission issue indeed. Fix is simple, make sure you check out the page layout page, then check it back in as published version.
    John Architect

  • SP 2013 - Use PowerShell to Add a Custom Web Part to a Page

    Hello Community,
    I need to add a custom web part to a page using PowerShell - has anyone done this and if so please provide guidance and code examples.
    Thanks!
    Tom
    Tom Molskow - Senior SharePoint Architect - Microsoft Community Contributor 2011 and 2012 Award -
    Linked-In - SharePoint Gypsy

    BTW, here is my current code:
    #$web= Get-SPWeb -Identity "http://c4968397007/sites/BRE"
    $Url = "http://c4968397007/sites/BRE"
    $pageUrl = "/SitePages/Home"
    $webpartzone = 2
    $index = 0
    $fileName = "wp_DistrictHomePage_VisualWebPart1.webpart"
    $web = Get-SPWeb $Url
    $web.AllowUnsafeUpdates=$true
     $webPartGallery = $web.Lists["Web Part Gallery"]
     Write-Host "Searching webpart $fileName in web part gallery"
      if($webPartGallery -eq $null)
       Write-Host("Unable to retrieve Webpartgallery");
     $webpart = $null;
     $webpart=$webPartGallery.Items | ? { $_.Title -eq $fileName}
      if($webpart -eq $null) {
       Write-Host("Unable to retrieve webpart: $fileName") -ForegroundColor Red
     else {
      Write-Host("----------Adding Webpart--------")-ForegroundColor Yellow
      $webpartmanager=$web.GetLimitedWebPartManager($pageUrl, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
      $errorMsg = "";
      $xmlReader = New-Object System.Xml.XmlTextReader($webpart.File.OpenBinaryStream());
      $webpart = $webpartmanager.ImportWebPart($xmlReader,[ref]"Error")
      $webpartmanager.AddWebPart($webpart, $webpartzone, $index);
      Write-Host("Webpart is added successfully") -ForegroundColor Green ;
    $SiteURL =$Url
    #---------------Test Page----------------------------
    $PageName="Test.aspx"
    $page=$web.lists["Pages"].Items | ? {$_.Name -eq $PageName}
    $page.File.CheckOut();
    Add-WebPartToPage "$SiteURL/Pages/$PageName" "Header" 0 "My Custom WebPart"
    $page.File.CheckIn("Added Web part to a page");
    $page.File.Approve("Added Web part to a page");
    Tom Molskow - Senior SharePoint Architect - Microsoft Community Contributor 2011 and 2012 Award -
    Linked-In - SharePoint Gypsy

  • Unable to add web part to SharePoint 2013 page

    hello,
    My account has full control on the site collection, and when I edit the page and click on the Add a Web Part, nothing happens.  I would expect to have a list of web parts that I can select from, but this does not appear.  What can I do to enable
    this or get web parts added to the page?
    Thanks
    Paul

    Hi Paul,
    We need to collect more information about your issue:
    1.Is there any customized script that might affect the issue?
    2.Could you please test the issue with another user account? Does it work before for your account?
    3.Please test the issue on other browsers and see if it works.
    Similar threads:
    https://social.technet.microsoft.com/forums/sharepoint/en-US/e4fc21d4-b703-454a-a135-6d28d23cb18a/unable-to-add-webpart-wpadder-is-missing
    http://sharepoint.stackexchange.com/questions/3883/cant-add-web-parts-to-a-page-as-a-user-with-full-control
    Regards,
    Rebecca Tu
    TechNet Community Support

  • Having the same web part twice on a page - how to distinguish parameters

    Hello,
    I've made a web that takes a set of custom properties . If I put the web part twice  on the same pages, all the web parts are using the same custom parameters. 
    I understand that the culprit is in line: public static string strList, but I wonder if there has been a work around
    public static string strList;
    [System.Web.UI.WebControls.WebParts.WebBrowsable(true),
    System.Web.UI.WebControls.WebParts.WebDisplayName("MY display name"),
    System.Web.UI.WebControls.WebParts.Personalizable(
    System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared),
    System.ComponentModel.Category("ShowFieldBasedOnURL Custom Properties"),
    System.ComponentModel.DefaultValue("")]
    Thank you
    Christos

    correct, that's what I have mentioned, and I didn't see any static method from the link that you have provided.
    Question is have you tried refactoring the code as per the example you have referenced.
    Usually you will get the error message when you call non static method within static method, you should make the property as static, otherwise you will get the error message.  so try changing the code to the link as per the forum thread
    you are referring to.
    see here-
    http://www.wictorwilen.se/Post/Web-Part-Properties-part-2-Editor-Parts.aspx
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/3aa35b0e-27f9-4dbb-ab8a-2fc1d7435850/custom-web-part-properties-in-visual-studio-2012
    https://www.nothingbutsharepoint.com/sites/devwiki/articles/pages/how-to-create-sharepoint-2010-custom-visual-webpart-properties.aspx
    Hope this helps!
    Ram - SharePoint Architect
    Blog - SharePointDeveloper.in
    Please vote or mark your question answered, if my reply helps you

  • Integrating Custom page with Standard Page

    Hi
    My Doubt is,
    i m working on iRec Module.
    i m integrating Custom page with Standard Page , Is it will affect the Background running Workflow.
    Thanx

    Hi 781261,
    It seems you are familiar with OTN forums, based on your profile.
    165 posts, 50+ questions and 15 unresolved.
    I hope you know forum etiquettes(you can refer http://forums.oracle.com/forums/ann.jspa?annID=914).
    Close your previous threads if they are answered/you got out of the issue yourself.
    One of your unclosed threads is:
    Re: Can we Fire PPR on DFF?
    regards,
    Anand

  • Access Exchange Service From SharePoint 2013 Custom Web part getting The request failed with HTTP status 401: Unauthorized.

    I want to Fill a drop down with Outlook Meeting of Current log-in user in SharePoint 2013 web part for default credentials I am using the following code
     ExchangeServiceBinding binding = new ExchangeServiceBinding();
                ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;
                binding.RequestServerVersionValue = new RequestServerVersion();
                binding.RequestServerVersionValue.Version = ExchangeVersionType.Exchange2010_SP2;
                binding.PreAuthenticate = true;
                binding.UseDefaultCredentials = true;
                binding.Credentials = CredentialCache.DefaultCredentials ; 
                string server = "https://*********/ews/Exchange.asmx";
                binding.Url = server;
    I Am Getting the Error "The request failed with HTTP status 401: Unauthorized."
    but when I Replace  the line  
    binding.Credentials = CredentialCache.DefaultCredentials ; 
    with 
     binding.Credentials = new NetworkCredential(userName, password, domain);
    Its run fine.  Is there any way I could able to use default credential.
      

    Hi,
    As this question is more relate to Exchange development, I suggest you post it to the corresponding forum, you will get more help and confirmed answers from there.
    http://social.msdn.microsoft.com/Forums/office/en-US/home?category=exchangeserver
    Best regards
    Patrick Liang
    TechNet Community Support

  • Best Practices in SharePoint 2010 ( Out of the box feature vs Custom Web Part, development )

    Hi
    How do we differentiate on when to allow custom web parts and when to use out of the box.
    What are the performance issues involved when we deploy a custom web part into the SharePoint server. 
    Why do some companies prefer to allow only out of the box features, and no custom work is done?

    SharePoint is a powerful, flexible server product that can provide a wealth collaboration environment right out of box.
    Best answer for your question is depend upon your requirement. Sometime Out of Box features will solve all the problem with little designing. But sometime your requirement need a Custom Web part / solution.
    With OOTB implementation the big advantage is easy to trouble shoot & fix the issues. You will also found tons of blogs on internet for OOTB features. In custom development, its hard to troubleshoot & identifying whether its SharePoint issue or Custom
    code issue.
    check the below article for more ideas.
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/1e7845ef-61e0-4d01-bb6c-92519e6d7139/sharepoint-2010-outofbox-best-practices?forum=sharepointgeneralprevious
    http://www.cdh.com/media/articles/Pages/SharePoint-out-of-the-box---To-customize-or-not-to-customize.aspx
    Master List of SharePoint 2010 On-Premises Custom Development Best Practices
    http://i.zdnet.com/whitepapers/Quest_WPW_SharepointDev_Custom_US_KS_v3.pdf
    Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. ****************************************************************************************** Thanks -WS MCITP(SharePoint 2010, 2013) Blog: http://wscheema.com/blog

  • How to fix javascript error/bug on custom web part of SharePoint 2013

    I have a custom web part with serveral business fields. This web part is installed on DispForm, EditForm an NewForm.
    But, I click on Attach File button and a javascrit error is throw on my browser's status bar.
    Line: 5279
    Character: 5
    Code: 0
    URI: http://mysite:4000/_layouts/15/form.debug.js?rev=vyMg8qjZfJ8La1jn7bQ2cg%3D%3D
    How to solve this problem? I think it is a javascript conflict
    Tarcísio Corte [email protected]

    Hi,
    1. You can create a simple demo web part without your custom code firstly, then insert it into your form pages to see if the similar issue would occur. If it works, then add your
    other code into it one after one. By doing this, it will be easier to find out the root cause of this issue.
    2. What browser do you use? Please try to use IE 10(SharePoint 2013), IE8(SharePoint2010).
    3. You can also debug your code using IE F12 Developer Tools.
    http://blogs.msdn.com/b/kaevans/archive/2011/04/25/debugging-javascript-with-the-ie-developer-tools.aspx
    If the issue still exists, I can suggest you provide more information for further research.
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Dennis Guo
    TechNet Community Support

  • SharePoint 2013 RSS Viewer not loading when other Custom web part using Update Panel or Ajax Timer control

    Hi,
    SharePoint 2013 RSS
    Viewer web part failing to complete loading when the page loads.
    This happens when having RSS Viewer and then adding a Custom webpart with an updatepanel and timer control.
    I  had used Ajax update panel and timer control to load the web part asynchronously after the main page is fully loaded.
    The RSS-Viewer web part hangs in loading state while the custom webpart loads just fine.
    The issue occurs when an like button click or Timer Tick event fires after the page
    is loaded.
    Haven't been able to track the issue.
    Couple of workaround I tried to call a server side button click event from the custom web part after the page gets fully loaded using JQuery shown below did not work out either.
     $(document).ready(function () {
                $('#<%= netButton2.ClientID %>').click();
    And 
    document.onreadystatechange = function () {
                if (document.readyState == "complete") {
                    $('#<%= netButton2.ClientID %>').click();
    Please let me know how to resolve this issue.
    Thanks,
    Franklin

    Hi Johan,
    The assignment of this user on the given task might be corrupted. Try to remove the resource from the task, publish the project, assign the resource again and publish again the project. If it is not working, try to unpublish the task (column "publish")
    and publih it again.
    Hope this helps,
    Guillaume Rouyre, MBA, MVP, P-Seller |

  • How to play share point library video in custom web part

    Hi  ,i want to play my share point library videos and computer videos  in custom web part , how can i do this ,playing static video and library video both are common.
    Thanks,
    Madhu.

    Do you want to create a player from scratch or use eg. the Silverlight media player:
    http://jomit.blogspot.de/2009/12/using-silverlight-media-player-of.html
    or   alternatively html5 and the <video> element (will probably require a couple of tweaks in the master page) ?
    Kind Regards
    Bjoern
    http://spviking.com
    Twitter: Follow @bjoern_rapp

  • Custom web parts in SharePoint 2013 becomes inactive when the session is idle for long time.

    Hi,
    We have a search center site with custom web parts and custom master pages. When the session is inactive for long time all the custom web parts in the page doesn't work, unless we close the browser and open it. Where as this is not the case with the
    OOB web parts. We are not able to identify the root cause as it works with OOB web parts and not the custom web parts.We were able to find that by increasing the session timeout of the web application we can avoid this issue.We do not want to increase the
    session timeout as the OOB web part works perfectly even when the user session is idle for long time.Is there any other alternative where we can acheive the same for custom web parts when the session is idle for long time?
    Thanks,
    Saranya

    Hi Saranya,
    According to your descirption, my understanding is that when the session is long time idle ,then custom web part will not work.
    I suggest you check if you have enable the session in the Page Level in the web.config. By default SharePoint disable the session state.
    In the web.config, you will see <page enableSessionState> tag. You can modify like below and test if it works.
    <pages enableSessionState=”true” ….. />
    Here is a detailed thread for your reference:
    Use Session State in SharePoint
    Best Regards
    Zhengyu Guo
    TechNet Community Support

  • Error:System.Web.HttpUnhandledException in Custom Web part for Sandbox solution

    Please Help...
    I have a sandbox solution for Custom Web part which has a 'Visual Web Part(sandbox)'.
    The solution builds, Packages & deploys successfully.
    But when adding this custom web part on a Sharepoint 'Web Part Page' it throws up the below Error:
    Same code when deployed as a Farm Solution works all well.
    Only difference between the two solutions being Farm solution has  'Visual web part'
    and Sandbox solution has 'Visual web part(sandbox)'
    ERROR:
    ======================================================
    [SPUserCodeSolutionExecutionFailedException: Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: An unexpected error has occurred.]
     Server stack trace:
      at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext
    executionContext)
      at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext
    executionContext)
      at Microsoft.SharePoint.UserCode.SPUserCodeAppDomain.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext executionContext)
      at Microsoft.SharePoint.UserCode.SPUserCodeWorkerProcessProxyForShim.ExecuteInternal(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext
    executionContext)
      at Microsoft.SharePoint.UserCode.SPUserCodeWorkerProcessProxy.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext
    executionContext)
      at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
      at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
     Exception rethrown at [0]:
      at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
      at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
      at Microsoft.SharePoint.UserCode.SPUserCodeWorkerProcess.ExecuteDelegate.EndInvoke(IAsyncResult result)
      at Microsoft.SharePoint.UserCode.SPUserCodeWorkerProcess.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, SPUserToken userToken, String currentAffinity, SPUserCodeExecutionContext executionContext)
      at Microsoft.SharePoint.UserCode.SPUserCodePoolableProcessConnection.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, SPUserToken userToken, String affinity, SPUserCodeExecutionContext executionContext)
      at Microsoft.SharePoint.UserCode.SPUserCodeExecutionHost.Execute(Type userCodeWrapperType, Guid siteCollectionId, SPUserToken userToken, String affinity, SPUserCodeExecutionContext executionContext)
      at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
      at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
     Exception rethrown at [1]:
      at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
      at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
      at Microsoft.SharePoint.Administration.ISPUserCodeExecutionHostProxy.Execute(Type userCodeWrapperType, Guid siteCollectionId, SPUserToken userToken, String affinityBucketName, SPUserCodeExecutionContext executionContext)
      at Microsoft.SharePoint.UserCode.SPUserCodeExecutionManager.Execute(Type userCodeWrapperType, SPSite site, SPUserCodeExecutionContext executionContext)
      at Microsoft.SharePoint.UserCode.SPUserCodeWebPartRemoteExecutionHelper.<>c__DisplayClassa.b__9()
      at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)
      at Microsoft.SharePoint.UserCode.SPUserCodeWebPartRemoteExecutionHelper.ExecuteRequestInSandBox(HttpContext context, SPWeb web, SPWebPartManager manager, SPUserCodeWebPart userCodeWebPart)
    [HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown.]
     Server stack trace:
      at System.Web.UI.Page.HandleError(Exception e)
      at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
      at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
      at System.Web.UI.Page.ProcessRequest()
      at System.Web.UI.Page.ProcessRequest(HttpContext context)
      at Microsoft.SharePoint.UserCode.SPUserCodeWebPartWrapper.ExecuteHttpRequest(SPUserCodeWebPartHttpRequestContext webPartExecutionContext, SPUserCodeWebPartHttpResponse httpRequestResponse)
      at Microsoft.SharePoint.UserCode.SPUserCodeWebPartWrapper.Execute(SPUserCodeExecutionContext executionContext)
      at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.ExecuteWrapper(SPUserCodeWrapper wrapper, SPUserCodeExecutionContext executionContext)
      at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
      at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
     Exception rethrown at [0]:
      at System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase)
      at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData)
      at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.CodeToExecuteWrapper.EndInvoke(IAsyncResult result)
      at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext
    executionContext)
    [InvalidOperationException: Using Menu.DynamicHoverStyle requires Page.Header to be non-null (e.g. <head runat="server" />).]
      at System.Web.UI.WebControls.Menu.EnsureRenderSettings()
      at System.Web.UI.WebControls.Menu.OnPreRender(EventArgs e, Boolean registerScript)
      at System.Web.UI.Control.PreRenderRecursiveInternal()
      at System.Web.UI.Control.PreRenderRecursiveInternal()
      at System.Web.UI.Control.PreRenderRecursiveInternal()
      at System.Web.UI.Control.PreRenderRecursiveInternal()
      at System.Web.UI.Control.PreRenderRecursiveInternal()
      at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    Hi!!
    Sure, Please find .cs and .ascx script below
    ==========.ascx===========================
    <%@ 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" %>
    <%@ Import Namespace="Microsoft.SharePoint" %>
    <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DynamicMenuWP.ascx.cs" Inherits="MenuWebPartProject.DynamicMenuWP.DynamicMenuWP" %>
    <asp:Menu ID="siteStructure" runat="server" Orientation="Horizontal"  StaticPopOutImageTextFormatString="" DynamicHoverStyle-BackColor="#CBE3F0" SkipLinkText=""
                                            StaticSubMenuIndent="10px"
    BackColor="#000000" CssClass="BIMenu" Font-Names="Verdana" Font-Size="1em"  DynamicHorizontalOffset="2" onmenuitemclick="siteStructure_MenuItemClick" Target="_blank">
                                            <StaticSelectedStyle
    BackColor="#507CD1" />
              <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" CssClass="BIMenuStaticformenu" />
              <DynamicHoverStyle BackColor="#CBE3F0" />
              <DynamicMenuStyle BackColor="#F2F3F4" BorderColor="#A7B4CE" ForeColor="Black" />
              <DynamicSelectedStyle BackColor="#507CD1" />
              <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" CssClass="BIMenuDynamicForMenu" />
            <StaticHoverStyle BackColor="#284E98" ForeColor="White" />
    </asp:Menu>
    ==========.cs===========================
    using System;
    using System.ComponentModel;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.WebControls;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    namespace MenuWebPartProject.DynamicMenuWP
        [ToolboxItem(false)]
        public partial class DynamicMenuWP : System.Web.UI.WebControls.WebParts.WebPart
            protected override void OnInit(EventArgs e)
                base.OnInit(e);
                InitializeControl();
            protected void Page_Load(object sender, EventArgs e)
                if (!IsPostBack)
                    ScorecardStructure ss;
                    List<ScorecardStructure> listSS = new List<ScorecardStructure>();
                        using (SPWeb web = SPContext.Current.Web)
                            SPList lists = web.Lists["MenuItems"];
                            if (lists.ItemCount > 0)
                                foreach (SPListItem item in lists.Items)
                                    ss = new ScorecardStructure();
                                    ss.title = Convert.ToString(item["Title"]);
                                    ss.ParentID = Convert.ToInt32(Convert.ToString(item["Parent ID"]));
                                    ss.ParentName = Convert.ToString(item["Parent Name"]);
                                    ss.MenuID = Convert.ToInt32(Convert.ToString(item["Menu ID"]));
                                    ss.menuName = Convert.ToString(item["Menu Name"]);
                                    ss.url = Convert.ToString(item["URL"]);
                                    ss.friendlyName = Convert.ToString(item["Friendly Name"]);
                                    listSS.Add(ss);
                    if (listSS.Count > 0)
                        List<ScorecardStructure> y = listSS.Where(s => s.ParentID == 0).ToList<ScorecardStructure>();
                        foreach (var x in y)
                            MenuItem newMenuItem = new MenuItem(x.menuName.ToString(), x.MenuID.ToString());
                            siteStructure.Items.Add(newMenuItem);
                            AddChildMenuItems(listSS, newMenuItem);
            private void AddChildMenuItems(List<ScorecardStructure> menuData, MenuItem parentMenuItem)
                if (menuData.Count > 0)
                    List<ScorecardStructure> childItems = menuData.Where(s => s.ParentID == Convert.ToInt32(parentMenuItem.Value)).ToList<ScorecardStructure>();
                    foreach (var v in childItems)
                        MenuItem newMenuItem = new MenuItem(v.menuName.ToString(), v.MenuID.ToString());
                        newMenuItem.NavigateUrl = v.url.ToString();
                        parentMenuItem.ChildItems.Add(newMenuItem);
                        // This code is used to recursively add child menu items filtering by ParentID
                        AddChildMenuItems(menuData, newMenuItem);
            protected void siteStructure_MenuItemClick(object sender, MenuEventArgs e)
                string st = e.Item.NavigateUrl;
                if (!(st.Equals(string.Empty)))
                    HttpContext.Current.Response.Redirect(st);
            class ScorecardStructure
                public string title { get; set; }
                public int ParentID { get; set; }
                public string ParentName { get; set; }
                public int MenuID { get; set; }
                public string menuName { get; set; }
                public string url { get; set; }
                public string friendlyName { get; set; }
            public bool IsPostBack { get; set; }

Maybe you are looking for

  • How can I have a shortcut key that is not a JMenuItem

    Hi, I'm trying to make "ctrl-f" a shortcut key in my program. I know I can do this as a JMenuItem by: menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, KeyEvent.CTRL_MASK)); However, I would rather not have it in the menu. How would I do

  • How to generate individual records out of a date interval in SQL?

    I have the following table in my db: group varchar(3), start date, end date, value number Obs.: The dates are in the format DD/MM/YYYY This table has this single record: 'group1', 01/11/2007, 15/11/2007, 3 I need to query this table (using SQL) and g

  • Error after Oracle Migration from DMTS into LMTS

    Hello , I'm sorry, I posted my question again from ABAP General into this forum ABAP Dictionary. I think that here someone can help me in order to proceed with my job in the Development and in production system. We are using SAP R/3 4.6C, with SAP ke

  • Value not appearing in the workbook

    Hi Friends, There are some values in the workbook which are prob appear through cell references. In dev sys its fine. We have moved the workbook to Quality, but here the values are not appearing. The value is period value which is not comming from ei

  • CPTL vs. CPTX - File Size

    Is it true that saving your files as CPTX can result in reducing your file size up to half the size from saving as a CPTL (Meaning CPTL is a lot larger)?