Muthu
Muthu

Reputation: 11

jquery Modal Dialog in asp.net Mvc 2

I have a grid of user info in ASP.NET Mvc 2. When i click on a user, i open a jQuery Modal dialog, which enables to edit the user.I am able to edit and save the user.

Can some one help me on how to do validation on this modal dialog using the asp.net mvc data annotaions on server side and display the validation message.

Upvotes: 1

Views: 647

Answers (1)

Prasanth
Prasanth

Reputation: 3041

Use this function to load all modal dialogue popups

function ShowPopup(popupID, pageUrl) {

            $("#" + popupID).empty();

            $("#" + popupID).dialog({
                autoOpen: false,
                modal: true,
                resizable: false,
                height: 'auto',

                width: 565 //set width of pop up
            });

            $("#" + popupID).html(popUpLoaderHtml);

            $.ajax({

                type: 'GET',
                url: pageUrl,
                cache: false,
                success: function (data) {
                    $("#" + popupID).empty();
                    $("#" + popupID).append(data);




                }
            });

            $("#" + popupID).dialog("open");

        }

Customise this method for any modal dialogue like this

function ShowCommentEditPopUp(popupID, CommentId) {


        ShowPopup(popupID, '/comments/edit/' + CommentId);
    }

Here the 'popupID' is the ID of the div where popup is loaded

Upvotes: 2

Related Questions