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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:06:16+00:00 2026-05-28T06:06:16+00:00

I need keep state on many-to-many modal dialogs in a progressive enhancement way in

  • 0

I need keep state on many-to-many modal dialogs in a progressive enhancement way in ASP.NET MVC project.
In my code when javascript is disabled modal dialog turn in navigation to another page and return, but when javascript is enabled the dialog open as a jquery modal dialog, its OK.
Im using this method to select action from click on view.
The code below show one master page calling detail page, there is the view and the controller. There is only one master calling one detail dialog but i have another views/controllers where one master can call many different detail dialog and sometimes one dialog can behave like a master page and call another dialog nested. Everything must keep state between calls.

The problem is its very complex, there is lots of code to keep state and manage dialog, i need repeat the same javascript and controller code everywhere, i wish some way to simplify it.
In view side need turn scripts generic to move to separate .js file and keep on view a minimum of javascript.
In controller side i search a lot for some generic way to do it like a filter or custom binder but cant find.

CONTROLLER

//######################################################################  
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using HYW.Models;
using HYW.Helpers;

namespace HYW.Controllers
{
    public class TesteController : Controller
    {
        //-------
        private object getValue(string key)
        {
            return Session[key];
        }
        private void setValue(string key, object value)
        {
            Session[key] = value;
            if (value == null) { Session.Remove(key); }
        }
        //-------
        [AcceptVerbs(HttpVerbs.Get)]
        public ActionResult createitem()
        {
            setValue("item", null);
            setValue("detail", null);
            return View("item");
        }
        //-------
        [HttpPost]
        [ValidateAntiForgeryToken]
        [HlpFltButtonSelector(Name = "action", Argument = "saveitem")]
        public ActionResult saveitem(testePg01 model)
        {
            ModelState.Clear();
            return View("item", model);
        }
        //-------
        [HttpGet]
        public ActionResult opendialog()
        {
            ModelState.Clear();            
            testePg02 p2 = (testePg02)getValue("detail");
            if (p2 == null) { p2 = new testePg02(); }
            return View("detail", p2);
        }
        //-------
        [HttpPost]
        [ValidateAntiForgeryToken]
        [HlpFltButtonSelector(Name = "action", Argument = "opendialog")]
        public ActionResult opendialog(testePg01 model)
        {
            ModelState.Clear();
            setValue("item", model);
            testePg02 p2 = (testePg02)getValue("detail");
            if (p2 == null) { p2 = new testePg02(); }            
            return View("detail", p2);
        }
        //-------
        [HttpPost]
        [ValidateAntiForgeryToken]
        [HlpFltButtonSelector(Name = "action", Argument = "savedialog")]
        public ActionResult savedialog(testePg02 model)
        {
            ModelState.Clear();
            setValue("detail", model);
            testePg01 p1 = (testePg01)getValue("item");            
            if (p1 == null) { p1 = new testePg01(); }
            p1.p02 = model;            
            return View("item", p1);
        }
        //-------
        [HttpPost]
        [ValidateAntiForgeryToken]
        [HlpFltButtonSelector(Name = "action", Argument = "canceldialog")]
        public ActionResult canceldialog(testePg02 model)
        {
            ModelState.Clear();
            testePg01 p1 = (testePg01)getValue("item");
            setValue("detail", null);
            if (p1 == null) { p1 = new testePg01(); }
            p1.p02 = null;
            return View("item", p1);
        }
        //-------
    }
}
//######################################################################  

VIEW

@model HYW.Models.testePg01
@{
    ViewBag.Title = "ITEM";
}
<script type="text/javascript">
    //-------------------------------------------------
    var url_trg = '@Url.Content("~/Teste/opendialog")';
    var url_prl = '@Url.Content("~/Images/waitplease.gif")';
    //-------------------------------------------------
    function onloadpartial() {
        configDetailDialog(url_trg, "#tempcontent", "section[id='main']", "Detail", "#opendialog");
    }
    //-------------------------------------------------
    function configDetailDialog(trgurl, containerselector, contentselector, dlgtitle, buttonselector) {
        //-------
        $(document).ajaxError(
            function (event, jqXHR, ajaxSettings, thrownError) {
                alert('[event:' + event + '], ' +
                        '[jqXHR:' + jqXHR + '], ' +
                        '[jqXHR_STATUS:' + jqXHR.status + '], ' + 
                        '[ajaxSettings:' + ajaxSettings + '], ' +
                        '[thrownError:' + thrownError + '])');
            });
        //-------
        $.ajaxSetup({ cache: false });
        //-------
        $(buttonselector).click(function (event) {
            event.preventDefault();
            openAjaxDialog(trgurl, containerselector, contentselector, dlgtitle);
        });
        //-------
    }
    //-------------------------------------------------
    function openAjaxDialog(trgurl, containerselector, contentselector, dlgtitle) {
        $.ajax({
            type: 'GET',
            url: trgurl,
            context: document.body,
            success: function (data) {
                var dlg = $(data).find(contentselector);
                $('#dlgdetail').remove();
                $(containerselector).append("<div id='dlgdetail'/>");
                $('#dlgdetail').append(dlg);
                $('#dlgdetail')
                    .css("border", "solid")
                    .dialog({
                        autoOpen: true,
                        modal: true,
                        title: dlgtitle,
                        open: function () {
                            configDetailDialog();
                        },
                        close: function (event, ui) {
                            $('#dlgdetail').remove();
                        }
                    })
                    .find("form").submit(function (event) {
                        alert('clicou ' + event);
                        var form = $(this);
                        var faction = "http://" + window.location.host + trgurl;
                        var fdata = form.serialize() + "&action:savedialog=savedialog";
                        $.ajax({                            
                            type: "POST",
                            url: faction,
                            data: fdata,
                            success: function (result) {
                                alert(result);
                            }
                        });
                        event.preventDefault();
                        $('#dlgdetail').dialog('close');
                    });
            }
        });
    }
    //-------------------------------------------------
</script>
<div id='tempcontent'>
</div>
<div id="formcontent">
    @Html.ValidationSummary(true, "Erro na pagina.")
    @using (Html.BeginForm())
    {
        @Html.AntiForgeryToken()
        <div>
            <fieldset>
                <legend>Item</legend>
                <div class="editor-label">
                    @Html.LabelFor(m => m.p01campo01)
                </div>
                <div class="editor-field">
                    @Html.TextBoxFor(m => m.p01campo01)
                    @Html.ValidationMessageFor(m => m.p01campo01)
                </div>
                <div class="editor-label">
                    @Html.LabelFor(m => m.p01campo02)
                </div>
                <div class="editor-field">
                    @Html.TextBoxFor(m => m.p01campo02)
                    @Html.ValidationMessageFor(m => m.p01campo02)
                </div>
                <p>
                    <input type="submit" style="background: #ffffff url('@Url.Content("~/Images/img01.png")')" value="opendialog" name="action:opendialog" id="opendialog" />
                    <input type="submit" style="background: #ffffff url('@Url.Content("~/Images/img02.png")')" value="saveitem" name="action:saveitem" id="action:saveitem" />
                </p>
            </fieldset>
        </div>
    }
</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-05-28T06:06:17+00:00Added an answer on May 28, 2026 at 6:06 am

    nobody really want to help you here lol !
    Someone here found a application called jqgrid-for-plsql on google code that can help you with some ideas.
    Someone here telling about some problems you can found with it.
    Leave jqgrid do all job for you on view side and forget about javascript independence.
    jqGrid is free and automatically create the grid with pagging, inline CRUD, metadata generated modal form CRUD, nested grids, support for FK fileds in grid and edition.
    Someone here is telling about another library called aspnetawesome.
    Someone here is telling about validation in these context.

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

Sidebar

Related Questions

I need to keep track of how many items are in a node of
I have the code below, now I need to keep track of the checkbox
I need to keep track of which user has visited which page how many
I need to keep the state of my Html control (I've a multi select
I need to keep track of around 10000 elements of an array in my
I need to keep a field in a data-base and update it with a
I need to keep track of std::set element by saving the iterator returned by
I need to keep track of number of hits on a particular item in
I need to keep a database up-to-date with a playlist's contents. I am using
I need to keep a colcounter variable inside the loop that will be used

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.