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 6819755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:20:38+00:00 2026-05-26T21:20:38+00:00

I’ve got an MVC 3 form in a strongly typed view where one of

  • 0

I’ve got an MVC 3 form in a strongly typed view where one of the fields I need submitted is inside of a jQuery dialog. I have not been able to get this field to be part of the POST parameters submitted. Why oh why?

The View:

@model My.Models.DialogFieldModel
@{
    ViewBag.Title = "Index";
}

<script type="text/javascript">
    $(document).ready(function () {
        $('#aDialog').dialog({
            autoOpen: true,
            height: 250, width: 400,
            modal: true,
            buttons: {
                "Ok!": function () {
                    $(this).dialog("close");
                }
            }
        });

    });
</script>

<h2>Index</h2>

@using (Html.BeginForm("PostDialogField", "DialogField"))
{
    @Html.ValidationSummary(true)
    <fieldset>

        @Html.HiddenFor(m => m.ID)
        @Html.DisplayFor(m => m.message)

        <div id="aDialog">
            <h3>Fill in this message!</h3>
            <div class="editor-field">
                @Html.EditorFor(m => m.message)
            </div>
        </div>

        <p><input type="submit" value="Submit Message" /></p>

    </fieldset>
}

The Model:

using System;

namespace My.Models
{
    public class DialogFieldModel
    {
        public int ID { get; set; }
        public String message { get; set; }

        public DialogFieldModel()
        {
            message = "Default";
        }
    }
}

The controller:

using System;
using System.Web;
using System.Web.Mvc;
using WellTrkd.Models;

namespace My.Controllers
{
    public class DialogFieldController : Controller
    {
        public ActionResult Index()
        {
            DialogFieldModel dfm = new DialogFieldModel(); // set default message
            return View(dfm);
        }

        [HttpPost]
        public ActionResult PostDialogField(DialogFieldModel dfm)
        {
            String message = dfm.message;
            if (message != "Default")
                //Yay!
                return RedirectToAction("Index");
            else // Boo
                return RedirectToAction("Index");
        }

    }
}

Unfortunately the #message field is never submitted along with the rest of the HTML POST parameters (checked in network tab of chrome dev view) unless I take it out of the dialog. The result is that in the PostDialogField action dfm.message contains the “Default” string, even if I’ve changed the message in the dialog.

I know I could add a hidden field to the form that is kept synchronized with the field in the dialog, but I feel I’m missing something. Any thoughts oh wise ones?

  • 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-05-26T21:20:39+00:00Added an answer on May 26, 2026 at 9:20 pm

    Your problem is that the element you turn into a dialog is moved out of the form towards a new dialog-element at the bottom of the DOM. And since it’s not part of the form any more, it won’t be submitted when the form is submitted.

    If you’d destroy the dialog when closing it, it would be moved back to where it was, but I can’t see if that’s what is desired. The other option is to sync elements.

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

Sidebar

Related Questions

I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a text area in my form which accepts all possible characters from
I have a view passing on information from a database: def serve_article(request, id): served_article
I have thousands of HTML files to process using Groovy/Java and I need to
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) 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.