本文介绍了如何在特定条件成立之前多次运行一个动作方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。

我在控制器中有一个动作方法如下:

Hi Everybody.
I have an action method in a controller as below:

public async Task<ActionResult> abc()
        {
            string nexturl = "this is a dynamic value"
            ViewBag.Data = nexturl;

            return View();
        }



上面的Action Method执行某些数据检查,然后将值传递给View并返回特定视图。在视图中如果我向下滚动到60px,我将被重定向到控制器中的另一个动作方法,如下所示:




Where above Action Method does some data checking then pass a value to the View and return a specific view. Within the view If I scroll down to 60px I'll be redirected to another action method in controller which is as below:

public async Task<ActionResult> abcGetMoreData(string nexturl)
        {
            if (nexturl != null)
            {
                // somme logic
            }
            ViewBag.Data = nexturl;
            return View("abc");
        }



上面的操作方法采用一个参数,该参数由带有ajax的'abc'视图提供。然后做一些检查并将nexturl的新值发送回视图。如果用户滚动下一个60像素,他/她将重定向到相同的操作方法'abcGetMoreData'并继续,直到nextUrl变为空。

我想要的是让用户轻松做这件事。我想一次加载所有数据,因此用户不应向下滚动以获取更多数据。我怎样才能实现这个目标?



我的尝试:



我没有尝试任何东西,因为我对C#和MVC都不熟悉。


Above action method takes a parameter which is fed by 'abc' view with ajax. then do some checking and sends back a new value for nexturl to the view. If the user scroll the next 60 px he/she will be redirect to the same action method 'abcGetMoreData' and continues until the nextUrl become null.
What I want is to make this thing easy for the user. I want to load all data in once so do user shouldn't scroll down to get more data. How can I achieve this?

What I have tried:

I haven't tried anything as far as I am very new to C# and MVC.

推荐答案


这篇关于如何在特定条件成立之前多次运行一个动作方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 15:59