locked
MVC - open VIEW in showModalDialog RRS feed

  • Question

  • User-1952516322 posted

    Hello,

    I have view called Index.cshtml in folder Views >> 'Views/Home/Index.cshtml'.

    When I tried to open this view by window.showModalDialog its not working??? 

     function OpenPopup() {
                var x = window.showModalDialog('~/Views/Tasks/Popup');
            }

    Saturday, January 19, 2019 9:47 AM

All replies

  • User475983607 posted

    Khalid Salameh

    Hello,

    I have view called Index.cshtml in folder Views >> 'Views/Home/Index.cshtml'.

    When I tried to open this view by window.showModalDialog its not working??? 

     function OpenPopup() {
                var x = window.showModalDialog('~/Views/Tasks/Popup');
            }

    There are several issue with the code snippet.

    View are returned by Action Method.  A View cannot be access directly with a link. 

    Secondly the tilde, ~, is a server side construction not JavaScript.

    The code should have the following syntax.

    function OpenPopup() {
    	var x = window.showModalDialog('/Controller/Action');
    }

    Saturday, January 19, 2019 3:38 PM
  • User-474980206 posted
    The tidle is only supported by parsed html components, not in JavaScript. You should use a helper


    var x = window.showModalDialog('@Url.Action(“popup”,”tasks”)');
    Sunday, January 20, 2019 7:58 PM