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

  • SEARCH
  • Home
  • 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 7950143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:10:42+00:00 2026-06-04T02:10:42+00:00

I have a domain aggregate that is displayed using a view model in a

  • 0

I have a domain aggregate that is displayed using a view model in a run-of-the-mill “Edit” view. The root object is Client, which has a nested property Referrer which is of type Contact. The Referrer’s first and last name are shown on the Client edit view, but I need the user to be able to spawn a “Create Contact” dialog if the referring contact isn’t already in the system. I’m attempting to do this in a jQuery dialog with a partial view for the Contact object. The problem is that if I put the button that spawns the Create Contact dialog inside of the Client object’s fieldset, the dialog doesn’t work. Simplified code:

Razor:

@using(Html.BeginForm()){
    @Html.ValidationSummary(true)
    <fieldset>
        <table>
            <tr>
                <td>
                    Client Name: 
                    @Html.TextBoxFor(m => m.ClientName)
                </td>
                <td>
                    Referred By: 
                    @Html.TextBoxFor(m => m.ReferrerName)
                    <button id="createContact">New...</button>
                </td>
            </tr>
        </table>
        <div class="lower-right-button">
            <input type="submit" value="Save" />
        </div>
    </fieldset>
}
<div id="createContactDialog" title="Create Contact" style="overflow: hidden;"></div>

jQuery:

$(document).ready(function() {
    $("#createContactDialog").dialog({
        autoOpen: false,
        resizable: false,
        width: 400,
        title: "Create Contact",
        modal: true,
        open: function(event, ui){
            $(this).load("@Url.Action("CreateContactPartial", "Contact")");
        },
        buttons: {
            "Cancel": function() {
                $(this).dialog("close");
            }
        }
    });
    $("#createContact")
        .button()
        .click(function() {
            $("#createContactDialog").dialog("open");
        });
});

If I take the createContact button out of the scope of the Html.BeginForm, the dialog shows up correctly, but the button is positioned nowhere near where I need it to be. If I leave the button as it is in the example above, the dialog displays for a second and then closes itself. Is there any way that I can have the button to launch the “Create Contact” dialog inside the Html.BeginForm? If not, are there other options to get the button where I want it to be without hacking the crap out of the DOM?

  • 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-04T02:10:44+00:00Added an answer on June 4, 2026 at 2:10 am

    The button event is causing the form to disappear. Change the click function to prevent that.

     $("#createContact")
            .button()
            .click(function (e) {
                $("#createContactDialog").dialog("open");
                e.preventDefault();
            }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following entities in my domain model. A group (an aggregate root)
I have a domain Aggregate, call it Order that contains a List of OrderLines.
I have a fairly simple domain model involving a list of Facility aggregate roots.
If I have an aggregate root which consists of say: class Parent { IEnumerable<Child>
I'm struggling with aggregates and aggregate roots. I have a natural aggregate root which
I have a Domain Model for Countries and States that looks like the following(see
I'm trying to apply the Aggregate Root pattern to my domain. I'm using Entity
I have a domain model that has the concept of an Editor and a
Say we have two aggregate roots in a domain model: Group and User. Now,
I have certain objects in my domain which are not aggregate roots/entities, yet 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.