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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:26:49+00:00 2026-06-06T13:26:49+00:00

I have a problem that is getting embarrassingly out of hand. I’m working with

  • 0

I have a problem that is getting embarrassingly out of hand.

I’m working with MVC and EF and have a model that the user can edit. I just got a new requirement that if it is edited, the edited property shall appear in red in the view for other users to see.

My model has a lot of properties, but the primary key is a GUID, and the model can have multiple parentIDs. So, for one a given GUID and ParentID I want to find what properties have been changed.

So far, which feels wrong, I have some jquery in my view that does the following

$("[name*='Request.']")
        .not(":hidden")
        .each(function () {
            var $this = $(this);
            $.ajax({
                url: '@Url.Action("IsChanged", "Shared")',
                data: { fieldName: $this.attr("name"), parentID: @Model.Request.ID },
                success: function (data) {
                    if (data) {
                        if ($this.is(":radio")) {
                            $this.parent().addClass("isChanged");
                        } else
                            $this.addClass("isChanged");
                    }
                }
            });
        });

This script works fine, if I try it with simply returning true from my ajax function. However, it’s the ajax function that is the problem. How do I find the changes? What I got so far is this:

public ActionResult IsChanged(string fieldName, int parentID)
    {
        using (MyEntities _db = new MyEntities())
        {
            string[] aName = fieldName.Split('.');

            // Count the number of version
            int versionCount = _db.SubRequests.Count(r => r.ParentID == parentID);
            // Get the first version
            SubRequest sr = _db.SubRequests.FirstOrDefault(r => r.ParentID == parentID);
            // Check if the count is the same for the specific value
            int changeCount = _db.ExecuteStoreQuery<int>("select count(parentID) from "+aName[0]+" where parentID = " + parentID + " and " + aName[1] +"='{0}'", THEVALUEINORIGINAL);


            bool isChanged = changeCount == versionCount;

            return Json(isChanged, JsonRequestBehavior.AllowGet);
        }
    }

What I’ve done so far doesn’t feel right, and obviously this doesn’t work, but I’m lost.

Let me know if this is understandable, or if you need more information. Should I scrap this idea and build something completely different (probably), or is there a way to save me?

  • 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-06T13:26:50+00:00Added an answer on June 6, 2026 at 1:26 pm

    I’m sure it’s not the prettiest way to do it, but I thought I’d share what solution I finally decided on, in the end, in case anyone else would ever be looking to do something similar.

    My jQuery ajax function remains the same, but in the controller I have the following:

    public ActionResult IsChanged(string fieldName, int parentID)
    {
        using (MyEntities _db = new MyEntities())
        {
            bool isChanged = false; 
    
                string[] aName = fieldName.Split('.');
    
                string strTableName = aName[0];
                string strFieldName = aName[1];
    
                string strQuery = String.Format("select distinct {0} from {1} where parentID = {2}", strFieldName, strTableName, parentID);
    
                isChanged = _db.ExecuteStoreQuery<dynamic>(strQuery).Count() > 1;
    
                return Json(isChanged, JsonRequestBehavior.AllowGet);
        }
    }
    

    Works fine for me. However, it’s a pretty heavy loading page, with all those ajax calls.

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

Sidebar

Related Questions

So I have a problem that I can not figure out. I am writing
I have a problem. I have a view that is getting back no results
i have a problem that i can't solve ! (sqlite3, but i think it
I have a GUI problem that I would like to get sorted out, but
I have a problem that I am getting IllegalArgumentException while reading a video file
I have a problem with an array that is getting returned from a query
I have a problem that I am getting an xml file from raw resource
I have a producer/consumer concurrency problem that I'm working on. The problem is that
I have problems getting some of my views aligned in a relative layout that
In a couple of scripts that I use I have problem that is intermittent.

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.