Mujahid Mujahid - 1 year ago 98
ASP.NET (C#) Question

changing attribute of a html div tag from

i have following in my html page and i want to change its Data-To attribute value from code behind in

<div id="camp" class="number count-to" data-from="0" data-to="125" data-speed="1000" data-fresh-interval="20"></div>

I have a javascript function that sets the value but i'm not able to set its value from code behind in my java script function is following...

<script type="text/javascript">

function myfunc() {
$('#camp').countTo({ from: 0, to: 100 });
my func();

i want to call my func from

Answer Source
<div id="camp" class="number count-to" data-from="<%= SomeFromValue %>" data-to="<%= SomeToValue%>" data-speed="1000" data-fresh-interval="20"></div>

Alternatively give it a runat="server" and set it from code behind:

<div runat=server id="camp" class="number count-to" data-speed="1000" data-fresh-interval="20"></div>

Somewhere in code behind:

 camp.Attributes.Add("data-to", "10");
 camp.Attributes.Add("data-from", "1");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download