Tried adding a Modal window but it just fails to work. The code itself works in a FormWebPart but not in a custom aspx page created via SPD.

**Working Code in FormWP**

```
<p><a href="javascript:portal_openModalDialog();">test link</a></p>
<script>
    function portal_openModalDialog() {
        var options = {    
            url: SP.Utilities.Utility.getLayoutsPageUrl('#' + location.href),    
            title: 'Edit web info',    
            allowMaximize: false,    
            showClose: true,    
            width: 800,    
            height: 330,    
            dialogReturnValueCallback: Function.createDelegate(null, 
                function (result, returnValue) {        
                    if (result == SP.UI.DialogResult.OK) {            
                        if (returnValue == null) {                
                            SP.UI.Notify.addNotification('Operation successful');                
                            SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);            
                        }            
                        else {                
                            location.href = returnValue;            
                        }        
                    }    
                }
            )
        }; 
        SP.UI.ModalDialog.showModalDialog(options);
    }
</script>

```

**custom ASPX page code (not working)**

```
<pre>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ Page Language="C#" inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register tagprefix="WebPartPages" namespace="Microsoft.SharePoint.WebPartPages" assembly="Microsoft.SharePoint, 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" %>

<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">
<meta name="WebPartPageExpansion" content="full" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled 2</title>

<SharePoint:ScriptLink runat="server" Name="sp.js" OnDemand="true" Localizable="false" />

</head>

<body>
<form id="form1" runat="server">
<p><a href="javascript:portal_openModalDialog();">test link</a></p>
<script>

function portal_openModalDialog() {
ExecuteOrDelayUntilScriptLoaded(function () {

var options = {    url: SP.Utilities.Utility.getLayoutsPageUrl('#' + location.href),    title: 'Edit web info',    allowMaximize: false,    showClose: true,    width: 800,    height: 330,    dialogReturnValueCallback: Function.createDelegate(null, function (result, returnValue) {        if (result == SP.UI.DialogResult.OK) {            if (returnValue == null) {                SP.UI.Notify.addNotification('Operation successful');                SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);            }            else {                location.href = returnValue;            }        }    })}; SP.UI.ModalDialog.showModalDialog(options);

}, "sp.js")

}
</script>

</form>

</body>

</html>
</pre>

```

Eventually I want the link to be part of a dataformwebpart that displays list items in a modal box.

Hope someone can assist.

Updated Code Almost working as can see box but also getting button stating 'Wrap focus to end of dialog'

```
<pre>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ Page Language="C#" inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register tagprefix="WebPartPages" namespace="Microsoft.SharePoint.WebPartPages" assembly="Microsoft.SharePoint, 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" %>

<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">
<meta name="WebPartPageExpansion" content="full" />

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled 2</title>

<Sharepoint:ScriptLink runat="server" Name="SP.js" Localizable="false"  ID="s3" LoadAfterUI="true"/>
<Sharepoint:ScriptLink runat="server" Name="SP.Core.js" Localizable="false"  ID="s1" LoadAfterUI="true"/>
<Sharepoint:ScriptLink runat="server" Name="SP.Runtime.js" Localizable="false"  ID="s2" LoadAfterUI="true"/>
<Sharepoint:ScriptLink runat="server" Name="SP.UI.Dialog.js" Localizable="false"  ID="s4" LoadAfterUI="true"/>

</head>

<body>
<form id="form1" runat="server">
<p><a href="javascript:portal_openModalDialog();">test link</a></p>
<script>

function portal_openModalDialog() {
ExecuteOrDelayUntilScriptLoaded(function () {

var options = {    url: SP.Utilities.Utility.getLayoutsPageUrl('../_layouts/settings.aspx'),    title: 'Edit web info',    allowMaximize: false,    showClose: true,    width: 800,    height: 330,    dialogReturnValueCallback: Function.createDelegate(null, function (result, returnValue) {        if (result == SP.UI.DialogResult.OK) {            if (returnValue == null) {                SP.UI.Notify.addNotification('Operation successful');                SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);            }            else {                location.href = returnValue;            }        }    })}; SP.UI.ModalDialog.showModalDialog(options);

}, "sp.js")

}
</script>

</form>
</body>

</html>

</pre>

```