asp.net - 函数无法在 <a> 标记中执行,但可以与 LinkBut​​ton 一起使用

标签 asp.net linkbutton static-functions

我有一个静态类(SS.U),其函数(GP)返回 true 或 false。我的问题是,当我在 <a> 中使用该函数时,它不会被触发。标签,但在 asp:LinkButton 内工作正常标签。由于某些原因我需要它们。这是我的代码行:

1) <asp:LinkButton Visible='<%# SS.U.GP("EditContactImage") %>' runat="server" ID="LB1" Text="EditImage"/>

2) <a visible='<%# SS.U.GP("EditRelations") %>' runat="server" id="R1">EditRelations</a>

3) <a visible='false' runat="server" id="R2">EditRelations</a>

第 1 行和第 3 行都正常工作,而第 2 行始终返回“visible = true”。 (示例中包含第 3 行,用于显示 <a> 标记实际上具有名为“visible”的工作属性)。我确实在 GP 函数中设置了一个断点,注意到只有第 1 行正在使用我的函数。
什么会导致 <a>标签不执行代码?

最佳答案

简短回答: HTML 控件不支持数据绑定(bind)。

详细答案在这里: When to use runat="server" on normal HTML

关于asp.net - 函数无法在 <a> 标记中执行,但可以与 LinkBut​​ton 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17727024/

相关文章:

ASP.NET LinkBut​​ton 在 IE7 中无法正确呈现

c++ - 将函数引用设置为来自其他 C++ 文件的非静态函数

c - 如何使用google test测试C的静态函数

c# 如何正确利用Page_init、ViewState和Page_Load?

asp.net - 我不断收到 "docker build"需要 1 个参数的错误

c# - 解决 ASP.NET MVC View 中的 "DataContext accessed after Dispose"错误

asp.net - XmlSerializer 可以反序列化为 Nullable<int> 吗?

asp.net - 使用其他 CSS 类时禁用 ASP.NET 4.0 中的链接按钮

asp.net - 排序gridview后错误的linkbutton命令参数

c - C语言中,如何使用非当前文件的静态函数?