Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
$('.detail-user').on("click", function () {
        var tr = $(this).parents('tr:first');
        var UserName = tr.find("#username").val();
        $("#DivToAppendPartialView").load("/Admin/DetailUser?username=" + UserName, function () {
            $("#DivToAppendPartialView").dialog({
                modal: true,
                width: 500,
                height: 438,
                title: "Detail User",
                resizable: false
            });
        });
    });


C#
public PartialViewResult DetailUser(string Username)
        {
            var user = (from a in db.LoginMasters join b in db.UserDetails on a.UserID equals b.UserID where a.username == Username select new { a.username, a.status, b.CompanyName, b.Address }).FirstOrDefault();
            UserDetail u = new UserDetail();
            u.username = user.username;
            u.status = user.status;
            u.CompanyName = user.CompanyName;
            u.Address = user.Address;

            return PartialView(u);
        }
Posted
Updated 29-Apr-15 21:23pm
v2

try adding
JavaScript
$( "#DivToAppendPartialView" ).dialog( "open" );
at the end of the click event.

try this

XML
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Test</title>
    <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
    <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
    <script>
        $(function () {
            $('.detail-user').on("click", function () {
                alert('test');
               // var tr = $(this).parents('tr:first');
                var UserName = 'somehardcoded';// tr.find("#username").val();
                var _url = "@Url.Action("DetailUser", "Home")" + "?username=" + UserName;
                $("#DivToAppendPartialView").load(_url, function () {
                    alert('loaded');
                    $("#DivToAppendPartialView").dialog('open');
                });
            });

            $("#DivToAppendPartialView").dialog({
                autoOpen: false,
                modal: true,
                width: 500,
                height: 438,
                title: "Detail User",
                resizable: false
            });

        });

    </script>

</head>
<body>
    <div>

        <input type="button" class="detail-user" value="Print"   />
    </div>
    <div id="DivToAppendPartialView" style="display:none"></div>
</body>
</html>


modify for your needs, let me know if u face any issue, it works fine for me
 
Share this answer
 
v2
Comments
Member 11645464 30-Apr-15 3:13am    
how to add it in the end of the click event please give me a full solution
Karthik_Mahalingam 30-Apr-15 3:16am    
$("#DivToAppendPartialView").dialog({
modal: true,
width: 500,
height: 438,
title: "Detail User",
resizable: false
});
$( "#DivToAppendPartialView" ).dialog( "open" );
Karthik_Mahalingam 30-Apr-15 3:17am    
basically, you should initialize the dialog in the document ready event and after that using 'open' , 'close' parameters you can operate the modal dialog
Member 11645464 30-Apr-15 3:23am    
but its not working, just open the div at the end of the table I want to open popup
Karthik_Mahalingam 30-Apr-15 4:31am    
ok wait, let me debug ur code
XML
<pre lang="Javascript">try this in
$(document).ready()

$("#DivID").dialog({
                modal: false,
                autoOpen: false,
                title: "",
                resizable: false
            });</pre>
 
Share this answer
 

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