I have an application page. I want to click a button to pop out a dialog that is in the another application page. The dialog shows up and vanished in the air quickly. Of cource it didn’t display the correct context of the page. I am using SharePoint 2010 and Visual Studio 2010. I used master page as well. Thanks.
<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
<link href="../Stylesheet.css" rel="stylesheet" type="text/css" />
<SharePoint:ScriptLink runat="server" Name="sp.js" OnDemand="true" LoadAfterUI="true" Localizable="false" />
</asp:Content>
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<div id="wrap">
<div id="nav">
<asp:Button ID="Edit" runat="server" Text="Edit" OnClientClick="javascript:Edit_Click()">
</asp:Button>
<script type="text/javascript">
function Edit_Click() {
SP.SOD.executeFunc("sp.js");
var options = SP.UI.$create_DialogOptions();
options.title = "My Dialog Title";
options.width = 400;
options.height = 600;
options.url = "/_layouts/Admin/test.aspx";
SP.UI.ModalDialog.showModalDialog(options);
};
</script>
</div>
The reason the dialog shows up and then disappers is because your asp:Button performs a postback.
Try using
to prevent the postback.