Tuesday, September 16, 2014

Get Modal Popup sharepoint 2010


  • Create a share point visual web part project and add below to the ascx page 
  • Create A Parent page and child page
Parent Page---> where web part is deployed
Child Page -- >  which you want to see in popup



protected void Page_Load(object sender, EventArgs e)
        {
            ShowBasicDialog(appSettings, "Announcements");
        }


        private void ShowBasicDialog(string Url, string Title)
        {
            //string heignt = "400";
            StringBuilder sb = new StringBuilder();
            sb.AppendLine(@"<script type=""text/ecmascript"" language=""ecmascript"">");
            sb.AppendLine(@"ExecuteOrDelayUntilScriptLoaded(openBasicServerDialog, ""sp.js"");");
            sb.AppendLine(@"    function openBasicServerDialog()");
            sb.AppendLine(@"    {");
            sb.AppendLine(@"        var options = {");
            sb.AppendLine(string.Format(@"            url: '{0}',", Url));
            sb.AppendLine(string.Format(@"            title: '{0}',", Title));
            sb.AppendLine(string.Format(@"            height: '{0}',", "550"));
            sb.AppendLine(string.Format(@"            width: '{0}'", "550"));
            sb.AppendLine(@"        };");
            sb.AppendLine(@"        SP.UI.ModalDialog.showModalDialog(options);");
            sb.AppendLine(@"    }");
            sb.AppendLine(@"</script>");
            ltScriptLoader.Text = sb.ToString();

            //<br>iframe<br>{<br>    background-image: url("../images/animatedspinner.gif");
        }
    }



add below key to app settings in web.config
  <add key="SPUrl" value="http://localhost:99/SitePages/Home.aspx" />

No comments:

Post a Comment