Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

SP.UI.ModalDialog.OpenPopUpPage not working in codebehind

$
0
0

I need to launch a InfoPath form in a Sharepoint Dialog.

Here is the Javascript:

function openInfopath(){//url = document.getElementById('TextBox1').Text;
            url ='http://devmarq/LenderDatabase/_layouts/FormServer.aspx?XmlLocation=/LenderDatabase/LenderBlog/LenderBlog-1-7.xml&ClientInstalled=true&OpenIn=Browser&DefaultItemOpen=1';
            SP.UI.ModalDialog.OpenPopUpPage(url,MyDialogCallback);}functionMyDialogCallback(dialogResult, returnValue){// Do stuff here
            alert('Dialog Closed');}

In ASP this works like a champ and displays the InfoPath form in a dialog.  Then when the dialog is closed, the alert message is displayed.
  
<a id="infoPathLink" href="#" onclick="openInfopath();return false;">Launch Infopath</a>  

However, running from codebehind, the dialog will not render:

protectedvoidOpenInfoPathForm(object sender,EventArgs e){// Call launchInfoPathForm()Page.ClientScript.RegisterStartupScript(this.Page.GetType(),"OpenInfopath","<script>openInfopath()</script>",false);}

Just to make sure I was not going crazy, I changed the javascript:

function openInfopath(){
  alert('Should Open InfoPath in a dialog');}

In both cases the alert is displayed so clearly the javascript is being executed.

Why does it not work with codebehind?



Bill Behning


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>