0

I have the following problem: So I built a search function for an OrderId in Nopcommerce and I want to update two values (Buyer Name) and (Purchase Reason) in a table in my main view instead of how it is now, where I render them in a partial view but it appears on the main page.

Example:

My search field, after I click search I want the result to appear below it without loading a new page

How it is at the moment after I click search button :

It pops up a new window with the results. Basically I want this panel here to appear in my first view as I explained earlier

My controller that renders the partial view:

I think I need to change something here right?

And here:Part of my SearchResult.cshtml partial view where the values appear

Part of my SearchResult.cshtml partial view where the values appear

I want it to appear somewhere here (My startview.cshtml as you can see I tried some things but nothing seems to work, Ill delete those) I want it to appear somewhere here (My startview.cshtml as you can see I tried some things but nothing seems to work, Ill delete those)

Thank you in advance!

odod
  • 23
  • 5
  • Post the relevant parts of your code as text, not screenshots. – Richard Deeming Jan 27 '22 at 10:40
  • some parts of the code contain sensitive information to the company and if I just leave it out it makes no sense either, I want to show the context. If you click on the screenshots you can see the code clearly – odod Jan 27 '22 at 11:47
  • [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask): *"**DO NOT post images of code, data, error messages, etc.** - copy or type the text into the question."* – Richard Deeming Jan 27 '22 at 11:56
  • [Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/a/285557): *"Images should only be used to illustrate problems that can't be made clear in any other way, such as to provide screenshots of a user interface."* – Richard Deeming Jan 27 '22 at 11:57

1 Answers1

1

You can achieve this using ajax call.

            var request = {
                OrderId: $('#OrderId').val(),
            }
            $.ajax({
                url: "/Home/DisplayBuyerName",
                type: "GET",
                data: request,
                contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
                success: function (data) {
                    $("#SearchResult").html('').html(data);
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(errorThrown);
                    return false;
                }
            });

html:

<div id="SearchResult"> </div>

So now your partial view is placed in SearchResult div.

Kiran Joshi
  • 1,758
  • 2
  • 11
  • 34