[英]Disable A button when my Queue is = 0 Asp.net MVC
How can I disable this button When my Queue is zero or null? 当我的队列为零或为空时,如何禁用此按钮?
Here is my view Button: 这是我的视图按钮:
@Ajax.ActionLink(" ", "BtnNext", null, new AjaxOptions
{
HttpMethod = "GET",
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "current",
LoadingElementId = "loading",
OnBegin = "ClearResults",
}, new { @class = "Middle-next dim btn btn-large-dim", @id = "Link1" })
here is the controller: 这是控制器:
public ActionResult BtnNext()
{
System.Threading.Thread.Sleep(1000);
var first = MyQueue.todayQueue.Dequeue();
TempData["QueueItem"] = first;
return PartialView("_queuenumber");
}
You can update your cshtml as below 您可以如下更新cshtml
<style>
.disabled {
pointer-events: none;
cursor: default;
}
</style>
@{
string cssClass = "Middle-next dim btn btn-large-dim";
if (MyQueue.todayQueue == null || MyQueue.todayQueue.length == 0)
{
cssClass += " disabled";
}
}
@Ajax.ActionLink(" ", "BtnNext", null, new AjaxOptions
{
HttpMethod = "GET",
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "current",
LoadingElementId = "loading",
OnBegin = "ClearResults",
}, new { @class = @cssClass, @id = "Link1" })
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.