How to open window in the same View in MVC 4?

后端 未结 1 1991
一整个雨季
一整个雨季 2020-12-12 07:39

I have a Telerik MVC grid in my view with a \"Download\" custom button. This button redirects to my Download action and this download action redirects me to the download vie

相关标签:
1条回答
  • 2020-12-12 08:07

    so you want to put an ajax call in your script tag. Make sure you have jquery referenced on the page. you call should look something like this

    $('#TableID tr').on('click', function() {
        $.ajax({
            url: "@(Url.Action("Action", "Controller"))",
            type: "POST",
            data: {
                id: $(this).attr('id')// from here http://stackoverflow.com/questions/5142422/get-id-of-selected-row-in-a-table-html
            }
            cache: false,
            async: true,
            success: function (result) {
                $(".Content").html(result);
                contentOverlay.load();
            }
        });
    });
    

    then on your controller

    public PartialViewResult Action(string id){
        Model model = //query the database
        return PartialView("_PartialView", model);
    }
    

    so when a row is clicked the method on your controller is called and a partial view is returned. Put that result into a div on your view and then pop up that div (we use jquery overlay but there are several different options). Hope this helps

    0 讨论(0)
提交回复
热议问题