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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:05:25+00:00 2026-06-07T19:05:25+00:00

I am using C#, MVC. I am having a problem with PartialView and jquery

  • 0

I am using C#, MVC.

I am having a problem with PartialView and jquery load working properly.

When the user clicks on a hyperlink called Kit, I call the following:

    public ActionResult KitsEdit(string id)
    {
        int idnbr = Convert.ToInt32(id);

        var Progs = db2.usp_KitInfo(idnbr)
                    .OrderBy(x => x.TDate).ToList();


        return PartialView(Progs);
    }

which loads a PartialView on the page fine.

the View has rows and for each row has an edit hyperlink.
When the user clicks on the Edit hyperlink, I show a dialog box where the user can modify that some of the info on that appears on each row and hit submit. This works fine the first time.

On submit, I call I do some validation and then call:

    $("#stlist").load('@Url.Action("KitsEdit", "Spr")' + '?id=' + '@Model.id'); 

as I need to reload the partial view on the page so the user can see the updated information.

The load of the page works fine on the surface. What happens though is that when I click on Edit hyperlink a SECOND time after I did the .load and the dialogbox shows up some of the functionality that worked before simply doesn’t work. For example, the checkbox doesn’t work in that if I click it, the value doesn’t get passes properly back to the controller action. Also, for the submit, I had some code on click but those don’t even work. It goes diectly to the controller action and bypasses all of the code in

    $("#submit").click(function ().

Note that this happens only after the load() is called.

Question: Is there anything besides the .load() that will load a PartialView on the page. If not, how can I get it to work properly with the .load().

Below is what the submit click looks like:

    $("#submit").click(function () {
    //  following .on code won't execute code inside of function so have it commented       
    // $("#submit").on("click", function () {  

         var inactivedate = $("#InactiveDate").val();

         var inactivecheck = $('#Inactive').is(':checked');

         var inactivereason = $('#InactiveReason option:selected').text();

         if ((!inactivedate || !$.trim(inactivedate)) && $('#Inactive_cb').attr('checked') == true) {
             alert('Inactive Date must be entered.');
             return false;
         }

         if ($('#Inactive_cb').attr('checked') == true && inactivereason == '<Choose>') {
             alert('Inactive Reason must be selected.');
             return false;
         }

         var url = '@Url.Action("EditTrain", "Spr")';


         $.ajax({
             type: "POST",
             url: url,
             async: false,
             data: $('#theForm').serialize()               
           });


         $("#stlist").load('@Url.Action("kitsEdit", "Spr")' + '?id=' + '@Model.spkrid');
         parent.$.fn.colorbox.close();

         return false;

     });
 });

Thanks in advance.

  • 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-07T19:05:26+00:00Added an answer on June 7, 2026 at 7:05 pm

    load function is injecting some new contents to the DOM dynamically . So the old event bindings wont work for the new elements. You need to use jQuery on

    Change

    $("#submit").click(function (e) {
      //some code 
    });
    

    to

    $(document).on("click","#submit",function (e) {
      e.preventDefault() // if you need
      //some code 
    });
    

    jquery on works for current and future elements.

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

Sidebar

Related Questions

I am having problem using mvc:resources in spring 3.1 configuration. Initially i was working
I'm using ASP.NET MVC + NHibernate + Fluent NHibernate and having a problem with
I'm using KnockoutJS with ASP.NET MVC, and I'm having a problem with broken bindings
I'm using ASP.NET MVC 3 to build an application, but i'm having a problem
I'm having a problem with JQGrid using ASP.NET MVC. I'm trying to follow this
I'm using the Telerik Extensions for ASP.NET MVC 3 and I'm having a problem
I am having a problem rendering my view in the layout page using mvc
I'm working on an ASP.NET MVC application. I'm having a problem where my Application_Error()
I've been having a problem regarding using AJAX with Spring MVC. I have a
I'm having a problem similar to jQuery $.ajax Not Working in IE8 but it

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.