c# - 如何使用 ASP.NET 设置数据属性?

标签 c# asp.net vb.net html

如何使用代码隐藏设置数据属性?

ASP.NET

<asp:Label ID="lbl" runat="server" Text="Value" />
<asp:Panel ID="pnl" runat="server" />    

VB

lbl.Text = "Text"
pnl.Attributes("data-attribute") = "200"
//Is this correct?

所需标记

<span id="lbl">Text</span>
<div id="pnl" data-attribute="200">Value</div>

最佳答案

pnl.Attributes("data-attribute") = "200"

关于c# - 如何使用 ASP.NET 设置数据属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26804968/

相关文章:

java - 从 xamarin java 绑定(bind)中删除 virtual 关键字

asp.net - AJAX 级联下拉列表未填充

c# - ASP.NET 用户控制交叉通信

c# - RouteValueDictionary 到 HtmlAttributes

c# - 使用 UnitofWork 模式的 Rhino 模拟 Entity Framework 不起作用

C# 无法理解静态属性如何工作

c# - 放置多个显示错误 :There is already an open DataReader associated with this Command which must be closed first 的 sql 命令时

javascript - Angular 和 ASP.NET MVC - 当我将参数传递给后端 Controller 时,参数为空

c# - 在 UserControl 中使用泛型类型的正确方法是什么?

vb.net - 什么时候可以在 VB.Net 中使用 GoTo 语句?