Dec 30, 2011

SharePoint 2010 Modal Dialog


Hi Guys,

This is a small post regarding the Sharepoint Modal Dialog. In this post I am going to expalin you how to call a Sharepoint Modal Dialog from the applications. For this demo I have taken the Sharepoint Project template in visual studio and added an application page to my project. And then I placed a hyper link on this page to call the modal dialog.

The class SP.UI.ModalDialog represents the modal dialog and the method showModalDialog displays the modal dialog with the dialog options which we provide. 

Here is the code (written in C# .cs file) to show the modal dialog by registering a script which calls the modal dialog

 string myScript = @"   var mymodalDialog; 
                                 function ShowDialogTest(myViewUrl) { 
                                    var options = { 
                                        url: myViewUrl, 
                                        tite: 'Demo Page', 
                                        allowMaximize: true, 
                                        showClose: true, 
                                        width: 600, 
                                        height: 400 }; 
                                       mymodalDialog = SP.UI.ModalDialog.showModalDialog(options); 
                                }";
            ScriptManager.RegisterStartupScript(this, this.GetType(), ClientID, myScript, true);
            string strUrl = "http://moresharepoints.blogspot.com";
            hLinkshow.NavigateUrl = "javascript:ShowDialogTest('" + strUrl + "')";


This is the output on click of hyperlink

You can find more on this from msdn.



No comments:

Post a Comment