Click here to Skip to main content
16,012,044 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
View
----
@Html.ActionLink("Register here", "RegisterUser", "login", null, new { @class = "openDialog", data_dialog_id = "aboutdialog", data_dialog_title = "register new user" })


Controler
----------
[HttpGet]
    public ActionResult RegisterUser()
    {
        return PartialView("_Register");
    }


_Layout Page
JavaScript
<script type="text/javascript">
        //function SavedData(data) {
        //    $(".dialog").dialog("close");
        //}
        //function ErrorSave(data) {
        //    alert(data.parsetext);
        //}
        //function BeginReq(data) {
        //    $.validator.unobtrusive.parse('#registerform');
        //}
        $(document).ready(function () {
            alert("hi");
            debugger;
            $(".openDialog").on("click", function (e) {
                alert("BBH");
                e.preventDefault();

                $("<div></div>").addClass("dialog").attr("id", $(this).attr("data-dialog-id")).appendTo("body").dialog({
                        title: $(this).attr("data-dialog-title"),
                        close: function () { $(this).remove(); },
                        modal: true,
                        width: 600,
                        left: 0,
                    })
                .load(this.href);
            });



            $(".close").on("click", function (e) {
                e.preventDefault();
                $(this).closest(".dialog").dialog("close");
            });
        })
    </script>


_partial view: _Register.cshtml
--------------------------------
@model MVC_ERP_APP.Models.RegisterUser


@using (Ajax.BeginForm("RegisterUser", "Login", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "PopUpDiv", OnBegin = "BeginReq", InsertionMode = InsertionMode.Replace, OnSuccess = "SavedData", OnFailure = "ErrorSave" }, new { ID = "registerform" }))
{
    <fieldset>
        <legend>New User</legend>
        <table class="table-bordered">
            <tr>
                <td>
                    @Html.LabelFor(model => model.username)
                </td>
                <td>
                    @Html.TextBoxFor(model => model.username)
                    @Html.ValidationMessageFor(model => model.username)
                </td>
            </tr>

            <tr>
                <td>
                    @Html.LabelFor(model => model.password)
                </td>
                <td>
                    @Html.TextBoxFor(model => model.password)
                    @Html.ValidationMessageFor(model => model.password)
                </td>
            </tr>

            <tr>
                <td>
                    @Html.LabelFor(model => model.RegDate)
                </td>
                <td>
                    @Html.TextBoxFor(model => model.RegDate)
                    @Html.ValidationMessageFor(model => model.RegDate)
                </td>
            </tr>

            <tr>
                <td>
                    @Html.LabelFor(model => model.email)
                </td>
                <td>
                    @Html.TextBoxFor(model => model.email)
                    @Html.ValidationMessageFor(model => model.email)
                </td>
            </tr>
            <tr>
                <td>
                    <input type="submit" value="Register" />
                </td>
            </tr>
        </table>
    </fieldset>
}



Error
-----
Uncaught TypeError: Object [object Object] has no method 'dialog'

Regards
Basheer Ahamed.B
Posted
Updated 1-Jan-15 0:35am
v2

1 solution

You must be missing the jquery ui required reference for the page you are rendering. Please check for the reference and also try and avoid using the class name as dialog as they cause ambiguity leading to conflicting error{pretty time taking and irritating to find trap the error.}

I hope you get.
Please post back your queries if any.
Thanks.
 
Share this answer
 
Comments
Basheer Belgod 2-Jan-15 5:13am    
Ya even i enter the UI file to my solution then also i am getting same error.

<script src="~/Scripts/jquery-ui-1.8.24.js"></script>
<script src="~/Scripts/jquery-ui-1.8.24.min.js"></script>

Same Error i am getting
Uncaught TypeError: Object [object Object] has no method 'dialog'
[no name] 2-Jan-15 6:22am    
Please use any one js. Use the jquery-ui-min.js remove the other one. Please try with this modification.

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