Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8493139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:55:28+00:00 2026-06-10T22:55:28+00:00

How exactly should data from the jquery dialog be passed to the Controller? I’m

  • 0

How exactly should data from the jquery dialog be passed to the Controller? I’m unsure what to put for the data (see Index.cshtml code)

Controller

public ActionResult CreateUser() {
        return PartialView("_Create", new RegisterModel());
    }

[HttpPost]
public ActionResult CreateUser(RegisterModel user) {
    //...
}

Index.cshtml

<script type="text/javascript">
$(document).ready(function () {
    $('#dialog').dialog({
        //...dialog information
        open: function(event, ui) {
            $(this).load('@Url.Action("CreateUser")');
        },
        buttons: {
            "Submit": function () {
                $.ajax({
                    url: 'Users/CreateUser',
                    type: 'POST',
                    data: /* What is passed here? */,
                });
            }
        }
    });

    $('#btnCreate').click(function (e) {
        e.preventDefault();
        $('#dialog').dialog('open');
    });

});
</script>

@Html.ActionLink("Create New User", "CreateUser", null, new { id= "btnCreate" })
<div id="dialog" title="Create User" style="overflow: hidden;"></div>

—Edit—
here’s the model that’s being called from the open function

Model

public class RegisterModel {
    [Required]
    [Display(Name = "User name")]
    public string UserName { get; set; }

    [Required]
    [DataType(DataType.EmailAddress)]
    [Display(Name = "Email address")]
    public string Email { get; set; }

    [Required]
    [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
    [DataType(DataType.Password)]
    [Display(Name = "Password")]
    public string Password { get; set; }

    [DataType(DataType.Password)]
    [Display(Name = "Confirm password")]
    [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
    public string ConfirmPassword { get; set; }

    [Required]
    [Display(Name = "Roles")]
    public string RolesId { get; set; }
    public IEnumerable<SelectListItem> RolesItem {
        get { return new SelectList(Roles.GetAllRoles()); }
    }
}

partial view

@model MvcApp.Models.RegisterModel

@{
    ViewBag.Title = "Register";
}

<h2>Create a New User</h2>
<p>
    Passwords are required to be a minimum of @Membership.MinRequiredPasswordLength characters in length.
</p>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

<div id="CreateModel"></div>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true, "Account creation was unsuccessful. Please correct the errors and try again.")
    <div>
        <fieldset>
            <table>
                <tr>
                    <td>@Html.LabelFor(m => m.UserName)</td>
                    <td>@Html.EditorFor(m => m.UserName)</td>
                    <td>@Html.ValidationMessageFor(m => m.UserName)</td>
                </tr>
                ... more fields... 

            </table>
        </fieldset>
    </div>
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:55:30+00:00Added an answer on June 10, 2026 at 10:55 pm

    I supposed you want to show the form to create a user in the dialog, if that so, just create your form inside this <div id="dialog" title="Create User" style="overflow: hidden;"></div> element as normal, just make sure you use javascript validation, otherwise the page will be refreshed and the dialog will get lost if the users submits invalidad information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I accidentally deleted my previous post. Could I know exactly why I should compile
i know it should be context. what exactly is a context though. usually when
I'm still not getting exactly how a custom CursorAdapter should work, so after hard
When sending data from a form to a second page, the value of the
I have application reads in data from text file. Recently I realized that I
i am adding data from vba excel using adodb into a mysql database everything
I need to make an excel file which would fetch data from connection to
I'm using Symfony2 Framework, and I want to update an entity with data from
I'm using jquery with datatable.editable plugin, I'm managing to add a dropdown from static
I have a php file which pulls some data from external API's, and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.