[英]getting redirected when searching from another view
ok, so i have a project (Asp net core) that i am working on and i have created the controller and the model and i have implemented a searching mechanism here好的,所以我有一个正在处理的项目(Asp net core),我已经创建了 controller 和 model 并且我在这里实现了搜索机制
public async Task<IActionResult> Index(string searchString)
{
var drugs = from m in _context.Drugs
select m;
if (!String.IsNullOrEmpty(searchString))
{
drugs = drugs.Where(s => s.Name.Contains(searchString));
}
return View(await drugs.ToListAsync());
}
and it works very well so the issue is i can't search from my home page whenever i add the search string and hit the button it redirects me to the drugs index i don't want that i have implemented a bootstrap modal and i want my results to be displayed there.so how can i search my model from another view without getting redirected please i need your help.它工作得很好所以问题是每当我添加搜索字符串并点击按钮时我都无法从我的主页搜索它会将我重定向到药物索引我不希望我已经实现了引导模式并且我想要我的结果将显示在那里。所以我如何从另一个视图搜索我的 model 而不会被重定向,我需要你的帮助。 Thanks a million
太感谢了
Presumably you are just using a standard HTML form to submit the "search".大概您只是使用标准的 HTML 表单来提交“搜索”。 It's not "redirecting" you;
这不是“重定向”你; you are literally telling the browser to request a new URL and display that in the browser tab/window.
您实际上是在告诉浏览器请求新的 URL 并将其显示在浏览器选项卡/窗口中。 If you want to remain on the same page, then you must use AJAX to make the request.
如果您想保持在同一页面上,则必须使用 AJAX 发出请求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.