Solution 1 :

Front-end

<div id="myDiv" runat="server" class="counter" data-cp-percentage="3" data-cp-color="#FF675B"></div>

Code-behind

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
    ' only setting the value once on initial load.
    If Not Page.IsPostBack Then
        Me.myDiv.Attributes("data-cp-percentage") = "1234"
    Else
        ' this would be where you could set a new value only on postbacks if you wanted
    End If
End Sub

Problem :

I have the following code line which puts a progress bar on the screen. I found the code on CodePen website and I’m still learning so please bear with me. If I change the value in data-cp-percentage then the progress bar changes to that percentage. There’s obviously CSS and Java too but I simply need to change the value in this line programatically in VB. I have tried giving the DIV an ID and but then still unsure how to change it.

 <div class="counter" data-cp-percentage="3" data-cp-color="#FF675B"></div>

So I tried..

    <div id="consistency" runat="server" class="counter" data-cp-percentage="3" data-cp-color="#FF675B"></div>

And in VB I tried..

consistency.data-cp-percentage=”22″

but I get error BC30456: ‘data’ is not a member of ‘System.Web.UI.HtmlControls.HtmlGenericControl’.

Comments

Comment posted by JohnPete22

Assign an

Comment posted by mark davies

Ah that’s awesome. Thank you so much.

By