none
programaticaly created button is hidden RRS feed

  • Question

  • i create button 'Обрасци' with Visual Studio 2010 C#. this button is changed button 'New document'. i created 2 views 'timI' and 'timII'. i customized those views. now i have a problem. when i use default view 'AllItems' my button 'Обрасци' displayed like on picture 

    when i use my custom views for example 'timI' my button 'Обрасци' is hidden and i receive default button 'Нови документ(New document)' like on picture below

    how i resolve this problem?

    Wednesday, October 9, 2019 12:37 PM

Answers

  • Hi,

    If you want to replace the default "New Document" ribbon button in Document library, please use the Location "Ribbon.Documents.New.NewDocument" in custom code. The following code for your reference.

    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <CustomAction
        Id="DemoHelloWorldButton"
        RegistrationType="List"
        RegistrationId="101"
        Location="CommandUI.Ribbon">
        <CommandUIExtension>
          <CommandUIDefinitions>
            <CommandUIDefinition
             Location="Ribbon.Documents.New.NewDocument">
              <Button
               Id="Ribbon.Documents.New.CustomNewDocument"
               Alt="Hello World Ribbon Button"
               Sequence="10"
               Image32by32="/_layouts/1033/images/formatmap32x32.png"
               Image32by32Left="-64"
               Image32by32Top="0"
               Command="Demo_HelloWorld"
               LabelText="Обрасци"
               TemplateAlias="o2"/>
            </CommandUIDefinition>
          </CommandUIDefinitions>
          <CommandUIHandlers>
            <CommandUIHandler
             Command="Demo_HelloWorld"
             CommandAction="javascript:alert('Hello World!');" />
          </CommandUIHandlers>
        </CommandUIExtension>
      </CustomAction>
    </Elements>

    More information:

    Customizing and Extending the SharePoint 2010 Server Ribbon

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by gogi1000 Monday, October 14, 2019 8:31 AM
    Thursday, October 10, 2019 3:14 AM
    Moderator

All replies

  • Hi,

    If you want to replace the default "New Document" ribbon button in Document library, please use the Location "Ribbon.Documents.New.NewDocument" in custom code. The following code for your reference.

    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <CustomAction
        Id="DemoHelloWorldButton"
        RegistrationType="List"
        RegistrationId="101"
        Location="CommandUI.Ribbon">
        <CommandUIExtension>
          <CommandUIDefinitions>
            <CommandUIDefinition
             Location="Ribbon.Documents.New.NewDocument">
              <Button
               Id="Ribbon.Documents.New.CustomNewDocument"
               Alt="Hello World Ribbon Button"
               Sequence="10"
               Image32by32="/_layouts/1033/images/formatmap32x32.png"
               Image32by32Left="-64"
               Image32by32Top="0"
               Command="Demo_HelloWorld"
               LabelText="Обрасци"
               TemplateAlias="o2"/>
            </CommandUIDefinition>
          </CommandUIDefinitions>
          <CommandUIHandlers>
            <CommandUIHandler
             Command="Demo_HelloWorld"
             CommandAction="javascript:alert('Hello World!');" />
          </CommandUIHandlers>
        </CommandUIExtension>
      </CustomAction>
    </Elements>

    More information:

    Customizing and Extending the SharePoint 2010 Server Ribbon

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by gogi1000 Monday, October 14, 2019 8:31 AM
    Thursday, October 10, 2019 3:14 AM
    Moderator
  • Hi,

    Thanks for marking my reply as answer. I’m pleased to know that the information is helpful to you. I hope you are delighted with the service we provided you.
    Here I will provide a brief summary of this post for your information.

    Issue Symptom:

    Customize ribbon button in Documents tab of the document library not works.

    Solution:

    Provide an example to replace the default "New Document" ribbon button in Document library.

    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <CustomAction
        Id="DemoHelloWorldButton"
        RegistrationType="List"
        RegistrationId="101"
        Location="CommandUI.Ribbon">
        <CommandUIExtension>
          <CommandUIDefinitions>
            <CommandUIDefinition
             Location="Ribbon.Documents.New.NewDocument">
              <Button
               Id="Ribbon.Documents.New.CustomNewDocument"
               Alt="Hello World Ribbon Button"
               Sequence="10"
               Image32by32="/_layouts/1033/images/formatmap32x32.png"
               Image32by32Left="-64"
               Image32by32Top="0"
               Command="Demo_HelloWorld"
               LabelText="Обрасци"
               TemplateAlias="o2"/>
            </CommandUIDefinition>
          </CommandUIDefinitions>
          <CommandUIHandlers>
            <CommandUIHandler
             Command="Demo_HelloWorld"
             CommandAction="javascript:alert('Hello World!');" />
          </CommandUIHandlers>
        </CommandUIExtension>
      </CustomAction>
    </Elements>

    Reference Links:

    Customizing and Extending the SharePoint 2010 Server Ribbon

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    23 hours 40 minutes ago
    Moderator