locked
Add a webpart in master page RRS feed

  • Question

  • How can I add a custom webpart in a master page of Sharepoint site colllection?Please help me.

    Thanks,

    Shubho


    Shubho

    Tuesday, September 25, 2012 1:01 PM

Answers

  • Yes you can also do that , 

    Can you please take the developer tool to check the existing image path from the browser from the user control.

    Also provide the screens shot of images with the developer tool


    Hiren Patel | Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.

    • Marked as answer by Lhan Han Thursday, October 4, 2012 3:21 AM
    Wednesday, September 26, 2012 8:40 AM

All replies

  • You cant add the webpart in the master page , 

    But you can add the user control in master page,

    For that you need to create one usercontrol , and register this control in the master page and then you need to use it in master page as below

    I have deployed the custom usercontrol at "/_controltemplates/ProjectName/MYCustomControl.ascx"

    location

    So in master page register this tag like

    <%@ Register TagPrefix="CC" TagName="CustomTag" Src="~/_controltemplates/ProjectName/MYCustomControl.ascx" %>

    Now use this usercontrol in master page like

    <CC:CustomTag id="myCustomControl" runat="server"></CC:CustomTag>

    Hope this will help you.


    Hiren Patel | Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.


    Tuesday, September 25, 2012 1:24 PM
  • Tuesday, September 25, 2012 1:26 PM
  • Hi Hiren,

    There is no code for registering the user control.Can u share once again?

    Thanks,

    Shubho


    Shubho

    Wednesday, September 26, 2012 4:13 AM
  • Hello Shobho,

    I have already shared.As i told previously first you need to deploy your user control , then you need to register the usercontrol in master page as below , Here you need to change your user control path in "Src" attribute as per your usercontrol location

    <%@ Register TagPrefix="CC" TagName="CustomTag" Src="~/_controltemplates/ProjectName/MYCustomControl.ascx" %>

    Now put your usercontrol in master page where ever you want as below

    <CC:CustomTag id="myCustomControl" runat="server"></CC:CustomTag>

    For more information refer the articles

    http://salaudeen.blogspot.in/2012/04/how-to-create-user-control-in.html

    http://blogs.msdn.com/b/kaevans/archive/2011/04/28/user-controls-and-server-controls-in-sharepoint.aspx


    Hiren Patel | Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.



    Wednesday, September 26, 2012 4:22 AM
  • Hi Shubo,

    You can add a webpart in master page in SharePoint 2010. Follow the below steps,

      • Open your custom master page in edit mode in SPD 2010
      • Go to design view and select the place where you want to insert the webpart
      • In the ribbon go to Insert --> Webpart
      • Save and check-in the master page

    Hope this helps.

    • Proposed as answer by Shantha Kumar T Wednesday, September 26, 2012 9:28 AM
    Wednesday, September 26, 2012 5:57 AM
  • Hi Shubo,

    i think you can go for custom delegate control to fullfill your requirement. for more information visit this blog http://www.codeproject.com/Articles/113704/SharePoint-2010-Master-Page-Customizations-Through


    Thanks.... ________________ Baba (MCTS, MCPD)

    Wednesday, September 26, 2012 6:21 AM
  • Hi Hiren,

    Webpart also has a .ascx file means usercontrol..So we can add that usercontrol also...isnt it? so,I had added this way whatever u told.Actually it takes a image which s stored in another webpart,.Thats y I had created that webpart.But I m not getting that image in master page .Is it as because of the way I had added the webpart in master page or its not getting the image url bocz in master page its only show the blank...


    Shubho

    Wednesday, September 26, 2012 7:41 AM
  • Yes you can also do that , 

    Can you please take the developer tool to check the existing image path from the browser from the user control.

    Also provide the screens shot of images with the developer tool


    Hiren Patel | Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.

    • Marked as answer by Lhan Han Thursday, October 4, 2012 3:21 AM
    Wednesday, September 26, 2012 8:40 AM