简体   繁体   English

将标签值传递给Asp.net中的进度栏​​值属性

[英]Pass label value to progress bar value property in Asp.net

I am using a progress bar in my web project. 我在Web项目中使用进度条。 I want to add label value getting from Code Behind to progress bar' data-percent value property. 我想添加从“代码隐藏”获取标签值到进度栏的“数据百分比值”属性。 However, I am getting error such as: 但是,我收到如下错误:

Error 217 'System.Web.UI.HtmlControls.HtmlGenericControl' does not contain a definition for 'text' and no extension method 'text' accepting a first argument of type 'System.Web.UI.HtmlControls.HtmlGenericControl' could be found (are you missing a using directive or an assembly reference?) 错误217'System.Web.UI.HtmlControls.HtmlGenericControl'不包含'text'的定义,并且找不到扩展方法'text'接受类型为'System.Web.UI.HtmlControls.HtmlGenericControl'的第一个参数(您是否缺少using指令或程序集引用?)

Codes are like this: 代码如下:

<div class="skillbar clearfix " data-percent="<asp:Label ID="lblYuzde" runat="server"></asp:Label>%">
 <div class="skillbar-title" style="background: #c0392b;"><span>TOPLAM</span>
 </div>
   <div class="skillbar-bar" style="background: #e74c3c;"></div>
   <div class="skill-bar-percent"><asp:Label ID="lblBlogAdet" runat="server" Font-Bold="true" ForeColor="navy" Font-Size="Medium"></asp:Label></div>
</div>

进度栏屏幕截图

Would you help me please to fix the problem in a simple way? 您能帮我简单的方法解决问题吗?

You can't do that. 你不能那样做。 You are essentially putting a span inside a data-percent . 您实际上是将span放在data-percent You should do this sort of thing from the Code Behind. 您应该从背后的代码中执行此类操作。

If you want to put the value into the data-percent attribute, I'd do something like this. 如果您想将值放入data-percent属性,我会做类似的事情。

ASPX Page ASPX页面

<div class="skillbar clearfix" runat="server" id="progressBar"></div>

Code Behind 背后的代码

progressBar.Attributes.Add("data-percent", "your-value");

See here for more . 看到这里更多

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM