【问题标题】:how to disable ActionLink in razor after 2 minutes2分钟后如何在剃刀中禁用ActionLink
【发布时间】:2019-01-13 14:16:00
【问题描述】:

第一次使用 StackOverflow。 我有一个包含不同数据的表,我想在两分钟后禁用 actionlink

<table class="table">
    <tr class="btn-danger">
        <th>
            @Html.DisplayNameFor(model => model._art.libelle)
        </th>
        <th>
            Image
        </th>
        <th>
            @Html.DisplayNameFor(model => model._art.prix_initial)
        </th>
        <th>
            Prix Courant
        </th>
        <th></th>
    </tr>

@foreach (var item in Model)
{
    <tr class="btn-primary">
        <td>
            @Html.DisplayFor(modelItem => item._art.libelle)
        </td>
        <td>
           <img  src="@Url.Content(item._art.img)" width="300" height="300"/>
        </td>
        <td>
            @Html.DisplayFor(modelItem => item._art.prix_initial)
        </td>
        <td>
            @{ var prix_calcule = item.valeur_courante
                    * 0.1 * item._art.prix_initial
                     + item._art.prix_initial;
            }
            @prix_calcule
        </td>


        <td id="test">
            <h1>@Html.ActionLink("Encherir", "Encherir", new { id_article = item._art.id }, new { @class = "btn btn-success" })</h1>
        </td>
    </tr>
  } 

</table>

我想在两分钟后禁用 actionLink “encherir”。 我已经尝试过 javascript,但不幸的是,它只会禁用表中的第一行。

【问题讨论】:

    标签: javascript c# asp.net razor


    【解决方案1】:

    一旦您向浏览器交付了某些内容,您的控制就非常有限。有一些方法可以用 Javascript 隐藏它,但用户可以关闭 javascript,这将永远保持它。

    不过,处理此问题的最佳方法仍然是使用 Javascript 将其隐藏,但随后还要在链接中包含过期令牌。给它一个唯一的加密值作为 GET 参数,告诉你它什么时候过期。然后,如果用户在两分钟后点击了他们不应该点击的链接,您可以解码该令牌并返回“抱歉,您的链接已过期”页面而不是真实页面。

    【讨论】:

      猜你喜欢
      • 2019-12-29
      • 2012-04-02
      • 2023-04-05
      • 2019-01-11
      • 2018-04-24
      • 2011-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多