0

Iam new to ASP.NET MVC . My question is:

I am developing an application in which on "Show Log" button click ,I need to show a popup window on which a grid view that get poppulated with dynamic Contents. I implemented the "Show Log" button in cshtml. And in its click event ,i mentioned a javascript function "OnShowLogClick". Inside javascript function "OnShowLogClick" I called my Controller Action(that returns the dynamic data to be binded inside the grid) through load method that is:

  $(#popupWindowDiv).load("@Url.Action("Action", "Controller")", null,
            function (response, status, xhr) {
                    if (status == "error") {
                        alert("An error occurred while loading");
                }
                else {

                }
            });

I have 2 Issues

1) On intial Click on "Show Log" button ,Controller action is invoked.but on second click javascript function is executed but controller action is not invoked.

2) Grid inside popupWindow is not poppulated with entire data model binded.Everytime only 9 entries are shown.

Please help me Thanks in advance

2
  • 2
    It would probably help to see your controller and view code snippets as well. As far as troubleshooting goes, try opening the network monitor in the the developer tools of whatever browser you're using to see if your AJAX request is getting through to your server and getting a successful response. This can help you diagnose whether the problems is in on the server or on the client page making the request. Also, try setting a breakpoint in your controller code to debug it and see if you're actually passing more than 9 log entries to your view. Commented Dec 24, 2013 at 6:39
  • I have solved my second issue.My first Issue still exists.I put a breakpoint in my controller code.Thats how i noticed that my controller code is invoked only on first time,but on second time "Show Log" button click ,its not invoked .Is there any speciality on calling controller code through load method Commented Dec 26, 2013 at 4:07

1 Answer 1

0

This Problem was due to cache in browser. When you same request second time at the time it get the output from the cache it was not called sever request second time so it has two way to resolve the this problem

1) If you add attribute [OutputCache(NoStore = true, Duration = 0, VaryByParam = "")] above the action so cache will not maintain for that request.

2) And second way is you can add cache is false in ajax request
Example

$.ajax({
            cache: false,
            type: "POST",
            url: "@(Url.Action("ActionName", "Controller"))",
            data:Model,
            success: function (data) {
            },
            error: displayerror
        });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.