Answered by:
How can I open an HTML page in a modal/popup window?

Question
-
Hi,
I create an application page in VS2010 to do the following:
- Query a web service for an XML
- Convert the XML to HTML using XslCompiledTransform (C#).
- Save the resulting HTML page on a local drive.
What I want?
I want to open the HMTL in a modal or popup window.
My first approach was to open the HTML using IE. So, I tried something like this:
System.Diagnostic.Process.Start("IExplore.exe", "C:\\myPath\\myFile.htm");
But for some reason it doesn’t work: What wrong?
Now I have a second approach but I need some help, please:
I want to open the HTML using a SharePoint modal or popup window.
How can I do that?
This is the idea:
The user clicks the query button and in background, we query the web service, convert the XML to HTML and finally open the HTML within or outside SharePoint.
……………………………………………………….
I’m open to ideas and suggestion.
What is the best approach?
How would you do it?
Thanks in advanced!
Sunday, June 17, 2012 3:43 AM
Answers
-
Hi,
Try this
link = new HyperLink();
link.Text = "Edit Link";
link.NavigateUrl = string.Concat("javascript: LinkShowDialog('",SPContext.Current.Web.Url, "Links.aspx')");Thanks,
Sudan
- Marked as answer by Shimin Huang Friday, June 29, 2012 6:37 AM
Friday, June 29, 2012 6:15 AM
All replies
-
Hi,
Refer the below URL.
http://www.chakkaradeep.com/post/Using-the-SharePoint-2010-Modal-Dialog.aspx
Thanks,
Sudan
- Proposed as answer by Bjoern H Rapp Sunday, June 17, 2012 7:13 AM
Sunday, June 17, 2012 5:36 AM -
Hi,
Refer the below URL.
http://www.chakkaradeep.com/post/Using-the-SharePoint-2010-Modal-Dialog.aspx
Thanks,
Sudan
Hi Sudan12,
How can I open the popup when the user clicks the button?
I'm using C#
Thx
- Edited by efebo Monday, June 18, 2012 12:54 PM
Monday, June 18, 2012 12:53 PM -
Hi,
If you have a function name LinkShowDialog, Then from the button click call javascript:linkShowDialog()
function LinkShowDialog(url) { var options = SP.UI.$create_DialogOptions(); options.url = url; options.height = 800; options.width = 1000; SP.UI.ModalDialog.showModalDialog(options); } javascript:LinkShowDialog('<%=SPContext.Current.Web.Url %>)
Thanks,
Sudan
Monday, June 18, 2012 2:14 PM -
Hi,
If you have a function name LinkShowDialog, Then from the button click call javascript:linkShowDialog()
function LinkShowDialog(url) { var options = SP.UI.$create_DialogOptions(); options.url = url; options.height = 800; options.width = 1000; SP.UI.ModalDialog.showModalDialog(options); } javascript:LinkShowDialog('<%=SPContext.Current.Web.Url %>)
Thanks,
Sudan
Hi Sudan12,
Thx again.
I need to call the function my code behind in C# (VS2010)
Can I do it using your method.
Thanks in advanced
- Edited by efebo Thursday, June 28, 2012 11:42 PM
Thursday, June 28, 2012 11:42 PM -
Hi,
Try this
link = new HyperLink();
link.Text = "Edit Link";
link.NavigateUrl = string.Concat("javascript: LinkShowDialog('",SPContext.Current.Web.Url, "Links.aspx')");Thanks,
Sudan
- Marked as answer by Shimin Huang Friday, June 29, 2012 6:37 AM
Friday, June 29, 2012 6:15 AM -
This is my function, is ok:
<script type="text/javascript">
function portal_openModalDialog() {
var options = SP.UI.$create_DialogOptions();
var tipo = document.getDocumentById(ddlTipo);
var id = document.getDocumentById(txtDocumento);
if (tipo) {
var vTipo = document.getDocumentById(ddlTipo).value;
alert(vTipo);
}
if (id) {
var vId = document.getDocumentById(txtDocumento).value;
alert(vId);
}
options.width = 500;
options.height = 250;
options.url = "http://monaco/consultas/" + vTipo + vId + ".html";
options.dialogReturnValueCallback = Function.createDelegate(null, portal_modalDialogClosedCallback);
SP.UI.ModalDialog.showModalDialog(options);
}
function portal_modalDialogClosedCallback(result, value) {
if (value == '1') {
this.statusId = SP.UI
.Status
.addStatus("Exito!", true);
SP.UI.Status.setStatusPriColor(this.statusId, "Green");
}
if (value == '0') {
this.statusId = SP.UI
.Status
.addStatus("Error!", true);
SP.UI.Status.setStatusPriColor(this.statusId, "Green");
}
setTimeout(RemoveStatus, 6000);
}
function RemoveStatus() {
SP.UI.Status.removeStatus(this.statusId);
}
</script>Thanks!
Friday, June 29, 2012 5:05 PM