简体   繁体   中英

Pass label value to progress bar value property in Asp.net

I am using a progress bar in my web project. 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?)

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 . 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.

ASPX Page

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

Code Behind

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

See here for more .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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