none
page open in modal dialog RRS feed

  • Question

  • Hi all,

    i having problem, i have some jsp pages link and i want to open those links in modal dialogue box and problem is, i want to use code behind technique and attach moss user to the url but it give me error i unable to open dialogue box on sharepoint in webpart, i have web part in which i have define those links like this here is my code.i am really tired to solve this issue.

     

    function ShowDialog(url) {

     

        var options = SP.UI.$create_DialogOptions();

       options.url = url;

        options.height = 300;

        options.width = 600;

        SP.UI.ModalDialog.showModalDialog(options);

     }

    code behind

     

     const string jsScriptURL = "/_catalogs/masterpage/FunctionCustom.js";

      SPUser currentuser = SPContext.Current.Web.CurrentUser;

                HtmlGenericControl scriptInclude = new HtmlGenericControl("script");

                scriptInclude.Attributes.Add("src",   SPContext.Current.Site.RootWeb.Url + jsScriptURL);

                Controls.Add(scriptInclude);

     

     

                //HyperLink link = new HyperLink();

                //link.Text = "View Calendar";

                //link.NavigateUrl = string.Concat("javascript: ShowDialog('", SPContext.Current.Site.RootWeb.Url, "/Lists/Calendar/calendar.aspx')");

                //this.Controls.Add(link);

     

     

                HyperLink link = new HyperLink();

                link.Text = "View";

                link.NavigateUrl = string.Concat("javascript: ShowDialog('", SPContext.Current.Site.RootWeb.Url, @"http://orapps.tapal:8080/tapal/lvapp/frameset2.jsp?U_id=" + currentuser.LoginName.Replace(@"TAPALWORLD\", "").TrimStart());

                this.Controls.Add(link);

    Your help would be highly appreciate
    Thanks 

     


    BestRegards|SharePoint Techies
    Saturday, October 15, 2011 7:33 AM

Answers

  • Hi Wasi

     

    As per the exception you have posted, I think you are missing a single quote. Do a view source and check  the script that is registered.

    Thanks

    • Marked as answer by Wasi Khan Saturday, October 15, 2011 1:45 PM
    Saturday, October 15, 2011 1:44 PM
  • Hi Wasi

    I have few queries.

    HyperLink4.NavigateUrl = string.Concat("javascript: ShowDialog('http://sharepoint14:44469/_layouts/WordViewer.aspx?id=/Shared%20Documents/0a9079e4-bac4-447c-b5d2-6ab68f7c6e8a.docx&Source=http%3A%2F%2Fsharepoint14%3A44469%2FSitePages%2FHome%2Easpx&DefaultItemOpen=1&IsDlg=1')");

    In the above code, ISdlg ="1", why have you added this query string. This querystring denotes it a pop-up and master page should not be applied. I quess you dont have to add it.

    Can you try using SP.UI.Dailog.js to open pop-up.

     

    function OpenDialog() {

    var Url=window.location.href;

    var url = _RemoveQueryStringsAndHash(Url);

    var NewPopUp = SP.UI.$create_DialogOptions();

    NewPopUp.url = "URL of the page";

    NewPopUp.width = 713;

    NewPopUp.height = 400;

    NewPopUp.title = "Title that should apper on the pop-up"

    NewPopUp.dialogReturnValueCallback = Function.createDelegate(null,CallbackFunc);

     

    SP.UI.ModalDialog.showModalDialog(NewPopUp);

     

    }

    function CallbackFunc(result, target)

    {

     

     

    if(result === SP.UI.DialogResult.OK)

    {

      //Code if OK is click

     

    }

    }

     

    try this out, let me know if it works. If yes we can then check what is wrong in your code

     

    Thanks

    • Marked as answer by Wasi Khan Friday, October 21, 2011 9:48 AM
    Thursday, October 20, 2011 10:38 AM

All replies

  • Hello Wasi,

     

    Could you please send the exact exception like js error or Code behind error.

     

    At least for you can mannualy try to insert you js file reference in Webpart or put you ShowDialog function in ascx file of user control if it is a visual webpart.

     

    Thanks

    Ajit


    ajit
    • Edited by Ajit.Jha Saturday, October 15, 2011 8:16 AM
    Saturday, October 15, 2011 8:11 AM
  • Thank you Ajit for your prompt reply,

    i am using simple webpart not visual webpart 

     

     

    Webpage error details

     

     

    here is the exception when i click on link of the jsp page, am i making mistake some where 

     

    Message: Unterminated string constant

    Line: 1

    Char: 116

    Code: 0

    URI: http://sharepoint14:44469/SitePages/viewer.aspx

     

     


    BestRegards|SharePoint Techies
    • Edited by Wasi Khan Saturday, October 15, 2011 8:37 AM change
    Saturday, October 15, 2011 8:35 AM
  • Hi Wasi

     

    As per the exception you have posted, I think you are missing a single quote. Do a view source and check  the script that is registered.

    Thanks

    • Marked as answer by Wasi Khan Saturday, October 15, 2011 1:45 PM
    Saturday, October 15, 2011 1:44 PM
  •  

    Thank you very much omkar, yes i forgot the quote and i was very much sufering just only for quote now i got that and now its working perfect 

    thanks for your prompt reply..:)


    BestRegards|SharePoint Techies
    Saturday, October 15, 2011 1:47 PM
  • can you tell me that i am trying open pdf file in modal dialog but its not opening the file.is there any other way to open pdf file in modal dialog 

    Thank you 


    BestRegards|SharePoint Techies
    Tuesday, October 18, 2011 7:06 PM
  • Hi Wasi,

     

    If I understood you correctly, what you want is the PDF should open as a model pop-up, user should be able to reat it. Correct me if I am wrong.

    Can you tell me location of the PDf file. Is it in a document library

     

    Thanks

    Wednesday, October 19, 2011 5:36 AM
  • Thank you for your reply, 

    yes you are right user can read the pdf file in modal dialog. basically we have oracale system which genrate pdf file which consist salary slip of employee  and we have custom webpart in which i have define some links

    the path of pdf file is :

    http://orapps/dev60cgi/rwcgi60.exe?server=Rep60_ORAPPS&report=c:\\ora6i\\hris\\reports\\Leave_Application.rep&userid=payroll/payroll@tapal&destype=cache&desformat=PDF&mode=bitmap

    pdf file path is the drive path. and i am unable to open this in modal dialog here is the code 

    here is the code of calling pdf file in modal dialog:

     

     HyperLink4.NavigateUrl = string.Concat("javascript: ShowDialog(event, "'http://orapps/dev60cgi/rwcgi60.exe?server=Rep60_ORAPPS&report=c:\\ora6i\\hris\\reports\\Leave_Application.rep&userid=payroll/payroll@tapal&destype=cache&desformat=PDF&mode=bitmap')");

                HyperLink4.Text = "Leave Application Form - Report";

                Image4.DescriptionUrl = URL1;

                Image4.ImageUrl = "~/sites/tapaltea/SiteAssets/LinkIcons/centraladmin_generalapplicationsettings_externalserviceconnections_32x32.png";

    Thank you

     


    BestRegards|SharePoint Techies
    Wednesday, October 19, 2011 6:04 AM
  • Hi

    You try this out.

    Open Central Admin. Go to application management. Select  the web application. Then Click on general settings.

    A dropdrown will come up. Select general settings again. a modal pop up will come up, In "Browser File Settings" sections select Permissive.

    Try this is out and let me know if it works.

     

    Thanks

    Wednesday, October 19, 2011 6:29 AM
  • I have done this before but no enhancement, any other way in code
    BestRegards|SharePoint Techies
    Wednesday, October 19, 2011 6:34 AM
  •  

    Ok, How does it come up, I mean does it come up with a open and save option?

    Wednesday, October 19, 2011 6:37 AM
  • no it does not show open and save option. it shows nothing like can not find page error 
    BestRegards|SharePoint Techies
    Wednesday, October 19, 2011 6:40 AM
  • That means there is something wrong in the path

    Use developer tool and check what is the path that gets rendered in the browser.

     HyperLink4.NavigateUrl = string.Concat("javascript: ShowDialog(event, "'http://orapps/dev60cgi/rwcgi60.exe?server=Rep60_ORAPPS&report=c:\\ora6i\\hris\\reports\\Leave_Application.rep&userid=payroll/payroll@tapal&destype=cache&desformat=PDF&mode=bitmap')");

    Check the URL when the page is rendered. I mean the URL property of the control.  And copy the URL and try openin it in the seperate browser.

     

    Wednesday, October 19, 2011 6:55 AM
  • it is opening in the separate browser, please check my code, am i making any mistake in code
    BestRegards|SharePoint Techies
    Wednesday, October 19, 2011 6:58 AM
  • please see the image i have attached, here i have given the url of the document of my sharepoint library. and it shows this error

    HyperLink4.NavigateUrl = string.Concat("javascript: ShowDialog('http://sharepoint14:44469/_layouts/WordViewer.aspx?id=/Shared%20Documents/0a9079e4-bac4-447c-b5d2-6ab68f7c6e8a.docx&Source=http%3A%2F%2Fsharepoint14%3A44469%2FSitePages%2FHome%2Easpx&DefaultItemOpen=1&IsDlg=1')");

                HyperLink4.Text = "Leave Application Form - Report";

                Image4.DescriptionUrl = URL1;

                Image4.ImageUrl = "~/sites/tapaltea/SiteAssets/LinkIcons/centraladmin_generalapplicationsettings_externalserviceconnections_32x32.png";


    BestRegards|SharePoint Techies
    Wednesday, October 19, 2011 7:03 AM
  • Hi Wasi

    I have few queries.

    HyperLink4.NavigateUrl = string.Concat("javascript: ShowDialog('http://sharepoint14:44469/_layouts/WordViewer.aspx?id=/Shared%20Documents/0a9079e4-bac4-447c-b5d2-6ab68f7c6e8a.docx&Source=http%3A%2F%2Fsharepoint14%3A44469%2FSitePages%2FHome%2Easpx&DefaultItemOpen=1&IsDlg=1')");

    In the above code, ISdlg ="1", why have you added this query string. This querystring denotes it a pop-up and master page should not be applied. I quess you dont have to add it.

    Can you try using SP.UI.Dailog.js to open pop-up.

     

    function OpenDialog() {

    var Url=window.location.href;

    var url = _RemoveQueryStringsAndHash(Url);

    var NewPopUp = SP.UI.$create_DialogOptions();

    NewPopUp.url = "URL of the page";

    NewPopUp.width = 713;

    NewPopUp.height = 400;

    NewPopUp.title = "Title that should apper on the pop-up"

    NewPopUp.dialogReturnValueCallback = Function.createDelegate(null,CallbackFunc);

     

    SP.UI.ModalDialog.showModalDialog(NewPopUp);

     

    }

    function CallbackFunc(result, target)

    {

     

     

    if(result === SP.UI.DialogResult.OK)

    {

      //Code if OK is click

     

    }

    }

     

    try this out, let me know if it works. If yes we can then check what is wrong in your code

     

    Thanks

    • Marked as answer by Wasi Khan Friday, October 21, 2011 9:48 AM
    Thursday, October 20, 2011 10:38 AM
  • thank you omkar for your reply,

    the above url is testing url. and the original url is also not working here is the original url of pdf file that file generated by oracle system in specified path 

    and all page are working fine even oracle form can open in popup but this report is not opening 

    here is the original url of that report 

    http://orapps/dev60cgi/rwcgi60.exe?server=Rep60_ORAPPS&report=c:\\ora6i\\hris\\reports\\Leave_Application.rep&userid=payroll/payroll@tapal&destype=cache&desformat=PDF&mode=bitmap


    BestRegards|SharePoint Techies
    • Edited by Wasi Khan Thursday, October 20, 2011 11:20 AM change
    Thursday, October 20, 2011 11:19 AM
  • Can you try with the code above.
    Thursday, October 20, 2011 12:04 PM
  • Hi omkar,

     

    it still not opening, i am doing this in bold

     

     

    function OpenDialog() {

     

        var Url = window.location.href;

     

        var url = _RemoveQueryStringsAndHash(Url);

     

        var NewPopUp = SP.UI.$create_DialogOptions();

     

        NewPopUp.url = "C:\AJAXDocumentViewer\Windows-DeveloperGuide-ProfessionalEdition-4.6.pdf";

        NewPopUp.width = 713;

     

        NewPopUp.height = 400;

     

        NewPopUp.title = "Title that should apper on the pop-up"

     

        NewPopUp.dialogReturnValueCallback = Function.createDelegate(null, CallbackFunc);

     

         SP.UI.ModalDialog.showModalDialog(NewPopUp);

     

    }

     

    function CallbackFunc(result, target) {

        if (result === SP.UI.DialogResult.OK) {

     

            //Code if OK is click

     

        }

     

    }

     

    HyperLink4.NavigateUrl = string.Concat("javascript: OpenDialog()");

     

     

     

     

    and i also try this 

     

     

     

     

    function OpenDialog(url1) {

     

        var Url = window.location.href;

     

        var url = _RemoveQueryStringsAndHash(Url);

     

        var NewPopUp = SP.UI.$create_DialogOptions();

     

        NewPopUp.url = url1;

        NewPopUp.width = 713;

     

        NewPopUp.height = 400;

     

        NewPopUp.title = "Title that should apper on the pop-up"

     

        NewPopUp.dialogReturnValueCallback = Function.createDelegate(null, CallbackFunc);

     

         SP.UI.ModalDialog.showModalDialog(NewPopUp);

     

    }

     

    HyperLink4.NavigateUrl = string.Concat("javascript: OpenDialog('C:\\AJAXDocumentViewer\\Windows-DeveloperGuide-ProfessionalEdition-4.6.pdf')");

     

     

    i have try both approches but its not working. my pdf file is not opening 

     


    BestRegards|SharePoint Techies
    • Edited by Wasi Khan Friday, October 21, 2011 6:52 AM changes
    Friday, October 21, 2011 6:50 AM
  • Hi Wasi

     

    HyperLink4.NavigateUrl = string.Concat("javascript: OpenDialog('C:\\AJAXDocumentViewer\\Windows-DeveloperGuide-ProfessionalEdition-4.6.pdf')");

    Any Specific reason to a string contact. I dont think it is required

    Friday, October 21, 2011 8:52 AM
  • Omkar,

    i have tested the new url of my document library pdf file its working fine with my modal dialog. i came to know that is the previous url which i was testing is wrong. and the script is correct which you have provided me.

    old url 

    http://orapps/dev60cgi/rwcgi60.exe?server=Rep60_ORAPPS&report=c:\\ora6i\\hris\\reports\\Leave_Application.rep&userid=payroll/payroll@tapal&destype=cache&desformat=PDF&mode=bitmap

    new

    "javascript: OpenDialog('http://sharepoint14:44469/TestLib/fw4.pdf

    problem was the wrong URL 

    i really appreciate you help and following on my thread, you given me your precious time i am really thankful to you.

    Thanks 

    Regards 


    BestRegards|SharePoint Techies
    Friday, October 21, 2011 9:41 AM
  • Hey

    Good you got it working. Glad to help you

    Friday, October 21, 2011 10:15 AM