This is a migrated thread and some comments may be shown as answers.

How to show view as popup when action is posted?

6 Answers 1126 Views
Window
This is a migrated thread and some comments may be shown as answers.
Santhosh
Top achievements
Rank 1
Santhosh asked on 28 Aug 2012, 01:51 PM

Hai

I am creating a MVC4 razor Application using Kendo controls. In my application I supposed to open a view as popup. For that I am using kendow window control.  Am using the below code to open the popup.

@(Html.Kendo().Window()
        .Name("Searchwindow")
    .Title("user Search")
        .LoadContentFrom("../usersearch")  
    .Draggable()
    .Resizable()
    .Width(700)
    .Visible(false)

 The view is open as popup and works fine. But whenever the post action occurs in the view the page is opened as page like http://localhost:4376/usersearch.

I have to show the same popup to the user when the form is posted. How to show the same popup when an action is posted on the view page? Is it possible to open the view as popup after the action completion?


Thanks

6 Answers, 1 is accepted

Sort by
0
Nohinn
Top achievements
Rank 1
answered on 28 Aug 2012, 03:00 PM
I don't quite understand what is your issue.
You post form data, then you would like to show a kind of message in a popup window but instead it loads the message view in the main window?
I mean, your issue is that it is doing a full postback?
0
Santhosh
Top achievements
Rank 1
answered on 29 Aug 2012, 05:22 AM
No i don't want to show the message in popup. I already opened the view with in the popup.. With  in that popup i am having one submit button. when the user  clicks that button my view is not opening in popup.. How to show the view within that popup when user clicks submit button?



Thanks
0
Nohinn
Top achievements
Rank 1
answered on 29 Aug 2012, 08:29 AM
You would need to load the content in an iframe so the submit just affects the popup content and not the general content.
I don't know if it is possible through mvc extensions, though for this case if you need it here is the html and javascript code you would need:
<div id="Searchwindow" name="Searchwindow" style="width:700px"></div>
$('#Searchwindow').kendoWindow({
    title: "user Search",
    content: "../usersearch",
    iframe: true,
    visible: false
}).data('kendoWindow').center();

If the relative url '../usersearch' doesn't work try to use the absolute url (it should create by default the iframe but just in case we set the flag to true).

The ".data('kendoWindow').center()" part is optional, just to have the window centered when you make it visible
0
Santhosh
Top achievements
Rank 1
answered on 29 Aug 2012, 12:35 PM
Hai Nohinn

thanks for your reply.. Your solution is not working for me. i have uploaded the resulted view page snap shot when the user click submit button. I have a simple application.  In that search user link will be shown in the home page. When the user click on that link user window will be shown within a kendow window.
This is code  i have used in layout 

   <script type="text/javascript">
        $(document).ready(function () {
            $("#user").bind("click", function () {
                var window = $("#userwindow").data("kendoWindow");
                window.center();
                window.open();
            });
        });
       
    </script>
</head>
<body>
                    <a href="#" id="user">Search User</a>
              
            <div class="tabscontent">
                @RenderBody()
            </div>
      
    @(Html.Kendo().Window()
        .Name("userwindow")
        .Title("User")
                   .LoadContentFrom("../User/Index1")
                .Draggable()
                .Resizable()
                .Width(736)
                .Visible(false)
                .Modal(true)
            )
  
</body>

If i click on the submit button in the pop up the popup is closed and the view is opened as plain page..  My requirement is when the user clicks the submit i need to do db action in the controller and i have to show the same popup again. How to achieve this?


Thanks
0
Nohinn
Top achievements
Rank 1
answered on 29 Aug 2012, 12:44 PM
So you need to do the post in the popup and the result view should be displayed in the same popup? [case 1]
Or you need to do the post in the popup, the result will be displayed in the page but having still the popup opened? [case2]

case 1:
Right now I think that the mvc helper for the kendo window does not have the option to make it use an iframe, so any form inside the window will put the response in the page doing a postback.
To fix it for now until kendo team updates these features in their helpers, you will need to create the window via javascript, so 0 mvc helper code.

case 2:
In case you are trying to achieve this, you will have to post the data with jquery in an ajax way, and in the callback function place the result you get on the page. That would not close the popup and you would get the result in the page.
0
Kai
Top achievements
Rank 1
answered on 29 Aug 2012, 01:48 PM
//js
<script>
('#divFoo').load("/Controller/Action")
</script>
 
@Html.kendo().window().name("wdwFoo").content(@<text><div id="divFoo"></text>)


Create a partial view, use the jquery call back function to then load a div tag with in your window using  ('#mydiv').load(callbackmsg). You can also us jquery ajax but load() will ensure that your window gets the newwest data
Tags
Window
Asked by
Santhosh
Top achievements
Rank 1
Answers by
Nohinn
Top achievements
Rank 1
Santhosh
Top achievements
Rank 1
Kai
Top achievements
Rank 1
Share this question
or