Click here to Skip to main content
15,888,733 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
What I have did so far,
Step 1:
a) Created a view Course and added some textboxes, dropdowns and an actionlink.
JavaScript
@Html.ActionLink("Search", "Search", "Search", new { id = "new-value-link", })


b) Then added a div, which is used to open a partial view as popup
XML
<div id="dialog">
</div>


c) On actionlink click, opened a partial view as popup through jquery
JavaScript
<script type="text/Javascript">
    $(document).ready(function () {
        
        $('#new-value-link').click(function () {
            var href = this.href;
            $('#dialog').dialog({
                modal: true,
                height: 480,
                width: 580,
                open: function (event, ui) {
                    $(this).load(href, function (result) {
                       
                        $('#idSearchlbx').click(function () {
                            var retCourseId = $("#idSearchlbx option:selected").val();
                            $('#dialog').dialog('close');
                            $.ajax({
                                type: "POST",
                                url: "/Course/Course/",
                                data: { "retCourseId": retCourseId },
                                dataType: "html",
                                success: function (evt) {
                                   
                                },
                                error: function (req, status, error) {
                                    alert("Error!Occured");
                                }
                            });
                        });
                        
                    });
                }
            });
            return false;
        });
    });
</script>


d) In partial view,
JavaScript
@Html.ListBoxFor(m => m.SelectedId, new SelectList(Model.Groups, "Value", "Text"), new { id = "idSearchlbx", style = "height:365px;width:550px;" })

On listbox item click, ID of selected item value will be passed to action- controller in parent view (through above mentioned jquery). In that action, I have fetch the details corresponding to that id and return the details as model object. (like return View(model)).But the values are not reflected in view.
Posted
Updated 3-Feb-13 23:16pm
v3
Comments
Jameel VM 4-Feb-13 5:14am    
You should set whatever the values return from the actionResult by using jQuery or javascript to the controls you want. another way to change the current ajax request to normal request.please make sure that if you are using ajax like your normal code please return the result as json.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900