0

I have created a blank aspx page in SPD2010 and I want to add a series of asp.net buttons that launch forms and other pages in modals when clicked.

The issue is that the buttons only work if I embed them on a page based from my main master page so I assume my blank aspx page requires some references.

<asp:Button ID="myButton" Text="Open" runat="server" OnClientClick="var options = {url: 'https://WebAddress/siteforms/_layouts/listform.aspx?PageType=8&ListId={219B4A5B-9750-4A42-BC3D-4C97BD594806}&RootFolder=', title: 'Amend};SP.UI.ModalDialog.showModalDialog(options);return false;"/>

Thanks

4
  • 1
    What kind of modal dialogs are you using? SharePoint is based on asp.net, so you would need to use only asp.net specially with old versions of SharePoint. Can I know why would you want to use server side controls to manage modal dialogs? You can do that easily with JS, and it's going to work with newer releases of SharePoint. Dec 3, 2016 at 18:35
  • Mohammed, I wish to have a blank page with several buttons in a simple HTML table, the buttons will launch my sharepoint forms in modals. If there is a way to do this without the server side controls then please give me an example. Thanks
    – JazzyN
    Dec 4, 2016 at 21:04
  • Hi @JazzyN, you can have have all that in an HTML design, without any server side control. But first, which SharePoint forms do you need to open? Dec 4, 2016 at 21:48
  • Just some Nintex forms
    – JazzyN
    Dec 5, 2016 at 8:53

1 Answer 1

2

To Open the SharePoint Modal dialog in the custom aspx page the following references need to be added.

<SharePoint:ScriptLink ID="ScriptLink1" Name="init.js" runat="server" OnDemand="false" LoadAfterUI="true" Localizable="false" />
<SharePoint:ScriptLink ID="ScriptLink2" Name="sp.init.js" runat="server" OnDemand="false" LoadAfterUI="true" Localizable="false" />
<SharePoint:ScriptLink ID="ScriptLink3" Name="sp.runtime.js" runat="server" OnDemand="false" LoadAfterUI="true" Localizable="false" />
<SharePoint:ScriptLink ID="ScriptLink4" Name="sp.core.js" runat="server" OnDemand="false" LoadAfterUI="true" Localizable="false" />
<SharePoint:ScriptLink ID="ScriptLink5" Name="sp.js" runat="server" OnDemand="false" LoadAfterUI="true" Localizable="false" />
<SharePoint:ScriptLink ID="ScriptLink7" Name="sp.ui.dialog.js" runat="server" OnDemand="false" LoadAfterUI="true" Localizable="false" />

and register the SharePoint.WebControls using below tag in the page

<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

and please make sure that you've added reference to the MicorsoftAjax.js library in the page to avoid issue with recognizing type of SharePoint ScriptLink

<script type="text/javascript" src="/_layouts/15/MicrosoftAjax.js"></script>
2
  • Hi Thanks, I now get this error when I load a page after using the above references: Error An error occurred during the processing of /sites/SitePages/untitled.aspx. Code blocks are not allowed in this file.
    – JazzyN
    Dec 4, 2016 at 20:56
  • Just figured out I need t amend the web.config file to bypass the code block. Is there another way?
    – JazzyN
    Dec 4, 2016 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.