在特定时间提交 MVC 后,是否有功能可以对 3 个文本框执行操作 Asp.net



我会尝试解释这一点,因为它看起来很复杂。 我有 3 个文本框输入,我想对第一个输入执行操作,然后在一段时间后自动对第二个输入执行相同的操作,在同一时间之后,对第三个输入执行操作。

<form action="@Url.Action("ShowResults")" id="sideForm" method="post" onsubmit="return SidebarValidation()" autocomplete="off">
<input type="text" class="form-control" id="firstInput" autocomplete="off" name="first" placeholder="Enter Keyword..." value="@Request["first"]"  required><br /><hr />
<input type="text" class="form-control" id="secondInput" autocomplete="off" name="second" placeholder="Enter Keyword..." value="@Request["second"]" ><br /><hr />
<input type="text" class="form-control" id="thirdInput" autocomplete="off" name="third" placeholder="Enter Keyword..." value="@Request["third"]" ><br /><hr />
<div class="col"><button type="submit" id="sdSubmit" name="sideSubmit" class="btn btn-outline-primary" style="font-family: poppins">Custom SEARCH</button></div>
</form>

这是 view.cshtml,如您所见,我有 3 个输入和提交按钮,当我单击该按钮时,我希望在第一个输入上执行操作,5 分钟后第二个输入,5 分钟后第三个输入,5 分钟后第一个输入再次,依此类推。

如果有人有线索,请帮忙!

我希望这会有所帮助。运行此控制台应用程序,提取所需的内容。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace FileAdda
{
public class Example
{
static string globalstr = "";
static List<string> list = new List<string>();
static void Main(string[] args)
{
//assume these as your input values.
list.Add("Value 1");
list.Add("Value 2");
list.Add("Value 3");
Run();
}
public static void Run()
{
// You can set it to whatever time you want.
int seconds = 5 * 1000;
var timer = new Timer(TimerMethod, null, 0, seconds);
Console.ReadKey();
}
//Put your logic in this method.
public static void TimerMethod(object o)
{
if (string.IsNullOrEmpty(globalstr))
{
globalstr = list.FirstOrDefault();
}
else
{
int lastindex = list.IndexOf(globalstr);
if (lastindex == (list.Count - 1))
{
globalstr = list[0];
}
else
{
globalstr = list[lastindex + 1];
}
}
Console.WriteLine($"The timer callback for {globalstr}");
}
}
}

最新更新