How to disable a link based on the database value (ASP page)

倖福魔咒の 提交于 2019-12-13 03:45:17

问题


I would like to disable a link based on the database value (ASP page). Does anyone know how to do this? Are there any example available? Need your help. Thanks.


回答1:


This is a pretty vague question but in Classic ASP you can use VBScript to test your database value and then Response.Write out either the anchor tag or just a span tag with the text:

<%
    If CBool(rs("showlink")) = True Then
      %>
        <a href="somewhere.asp">Link Text</a>
      <%
    Else
      %>
        <span>Link Text</span>
      <%
    End If
%>

This assumes that you are getting a recordset back from the database (named rs) and that it has a field on it called "showlink" that will indicate if the anchor tag should be displayed or not. Small side note: Keep in mind that showing or hiding the anchor tag is not a replacement for proper authentication/security.



来源:https://stackoverflow.com/questions/1255645/how-to-disable-a-link-based-on-the-database-value-asp-page

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!